Guest User

Untitled

a guest
Oct 31st, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.15 KB | None | 0 0
  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.  
  7. pushd .
  8. set SEP=  
  9. set PFILE=path.txt
  10. set CLIPDATA=
  11.  
  12. rem Enumerate command line arguments
  13. :next
  14. if "%~1"=="" goto end
  15. echo Adding %1
  16. rem This will store relative path to the file
  17. set RELPATH=
  18.  
  19. rem Start with the deepest folder
  20. %~d1
  21. cd %~dp1
  22. :next_level
  23. if EXIST %~dp1%PFILE% goto found
  24. rem Topmost level:
  25. if "%~dp1"=="%~d1\" goto notfound
  26.  
  27. rem Otherwise, one level up
  28. for %%I in (%CD%) do set RELPATH=%%~nxI/%RELPATH%
  29. cd ..
  30. goto next_level
  31.  
  32. :notfound
  33. rem Only file name, without any path
  34. set CLIPDATA=%CLIPDATA%%~nx1%SEP%
  35. goto itemend
  36.  
  37. :found
  38. rem Base + relative path + filename
  39. FOR /F %%f IN (%PFILE%) DO set CLIPDATA=%CLIPDATA%%%f/%RELPATH%%~nx1%SEP%
  40. goto itemend
  41.  
  42. :itemend
  43. rem Next command line argument
  44. shift
  45. goto next
  46. :end
  47.  
  48. if "%CLIPDATA%"=="" goto skipclip
  49. rem Cunning way to echo without newline
  50. <nul set /p =%CLIPDATA%| clip
  51. :skipclip
  52.  
  53. popd
Advertisement
Add Comment
Please, Sign In to add comment