Advertisement
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.
- rem If you're on <<< Windows Server 2003, you'll need clip.exe.
- 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 %CD%\%PFILE% goto found
- rem Topmost level:
- if "%CD%"=="%~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
- if NOT "%CLIPDATA%"=="" set CLIPDATA=%CLIPDATA%%SEP%
- set CLIPDATA=%CLIPDATA%%~nx1
- goto itemend
- :found
- rem Base + relative path + filename
- if NOT "%CLIPDATA%"=="" set CLIPDATA=%CLIPDATA%%SEP%
- FOR /F %%f IN (%PFILE%) DO set CLIPDATA=%CLIPDATA%%%f/%RELPATH%%~nx1
- goto itemend
- :itemend
- rem Next command line argument
- shift
- goto next
- :end
- if "%CLIPDATA%"=="" goto skipclip
- rem Cunning way to echo without newline
- echo "%CLIPDATA%"
- 0<nul set /p ="%CLIPDATA%"|clip
- :skipclip
- popd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement