I want to implement a batch script in Windows 7 that iterates over all files in a folder and it cuts the folder prefix, e.g. Folder = "C:\A\B\" and the file = "C:\A\B\C\D.E" should output "C\D.E". My current code looks like this:
setlocal ENABLEDELAYEDEXPANSION
SET DIRECTORY=C:\DEV\SVN\QA\
for /R %DIRECTORY% %%f in (*.*) do (
REM GET RELATIVE PATH
echo File=%%f
echo Path=%TARGET_PATH_FOR_SOURCE%
set result=%f:!TARGET_PATH_FOR_SOURCE!=%
echo Result=!result!
)
I get the following result:
File=C:\DEV\SVN\QA\1.0\A\B\C.txt
Path=C:\DEV\SVN\QA\1.0
Result=C:\DEV\SVN\QA\1.0= <<< Expected result: "A\B\C.txt"
I found this here and tried this in the loop without success. Can you help me please?
Thank you!