Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- rem Copies to clipboard paths to the chosen files on the web storage, e.g.
- rem C:\Temp\Img\test.png ---> http://example.com/lib/Img/test.png
- rem Looks for a file named PATH.TXT which contains the base web address
- rem in this folder, then the parent folder, etc.
- pushd .
- set SEP=
- set PFILE=path.txt
- set CLIPDATA=
- rem Enumerate command line arguments
- :next
- if "%~1"=="" goto end
- echo Adding %1
- rem This will store relative path to the file
- set RELPATH=
- rem Start with the deepest folder
- %~d1
- cd %~dp1
- :next_level
- if EXIST %~dp1%PFILE% goto found
- rem Topmost level:
- if "%~dp1"=="%~d1\" goto notfound
- rem Otherwise, one level up
- for %%I in (%CD%) do set RELPATH=%%~nxI/%RELPATH%
- cd ..
- goto next_level
- :notfound
- rem Only file name, without any path
- set CLIPDATA=%CLIPDATA%%~nx1%SEP%
- goto itemend
- :found
- rem Base + relative path + filename
- FOR /F %%f IN (%PFILE%) DO set CLIPDATA=%CLIPDATA%%%f/%RELPATH%%~nx1%SEP%
- goto itemend
- :itemend
- rem Next command line argument
- shift
- goto next
- :end
- if "%CLIPDATA%"=="" goto skipclip
- rem Cunning way to echo without newline
- <nul set /p =%CLIPDATA%| clip
- :skipclip
- popd
Advertisement
Add Comment
Please, Sign In to add comment