Advertisement
himself

Untitled

Oct 31st, 2013
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. rem Copies to clipboard paths to the chosen files on the web storage, e.g.
  3. rem    C:\Temp\Img\test.png  --->  http://example.com/lib/Img/test.png
  4. rem Looks for a file named PATH.TXT which contains the base web address
  5. rem in this folder, then the parent folder, etc.
  6. rem If you're on <<< Windows Server 2003, you'll need clip.exe.
  7.  
  8. pushd .
  9. set SEP=  
  10. set PFILE=path.txt
  11. set CLIPDATA=
  12.  
  13. rem Enumerate command line arguments
  14. :next
  15. if "%~1"=="" goto end
  16. echo Adding %1
  17. rem This will store relative path to the file
  18. set RELPATH=
  19.  
  20. rem Start with the deepest folder
  21. %~d1
  22. cd %~dp1
  23. :next_level
  24. if EXIST %CD%\%PFILE% goto found
  25. rem Topmost level:
  26. if "%CD%"=="%~d1\" goto notfound
  27.  
  28. rem Otherwise, one level up
  29. for %%I in (%CD%) do set RELPATH=%%~nxI/%RELPATH%
  30. cd ..
  31. goto next_level
  32.  
  33. :notfound
  34. rem Only file name, without any path
  35. if NOT "%CLIPDATA%"=="" set CLIPDATA=%CLIPDATA%%SEP%
  36. set CLIPDATA=%CLIPDATA%%~nx1
  37. goto itemend
  38.  
  39. :found
  40. rem Base + relative path + filename
  41. if NOT "%CLIPDATA%"=="" set CLIPDATA=%CLIPDATA%%SEP%
  42. FOR /F %%f IN (%PFILE%) DO set CLIPDATA=%CLIPDATA%%%f/%RELPATH%%~nx1
  43. goto itemend
  44.  
  45. :itemend
  46. rem Next command line argument
  47. shift
  48. goto next
  49. :end
  50.  
  51. if "%CLIPDATA%"=="" goto skipclip
  52. rem Cunning way to echo without newline
  53. echo "%CLIPDATA%"
  54. 0<nul set /p ="%CLIPDATA%"|clip
  55. :skipclip
  56.  
  57. popd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement