Relative path for subdirectories from dir command?
Posted: 04 Jan 2009 14:50
I'm trying to make a batch that will make a list of all the images in a folder, and all its subdirectories. However, as this requires /s with the dir command the entire path is listed. I would like just the relative path listed.
Here is the current script;
I'm not sure how to go about doing this, I was thinking that trimming the current directory path from %%a before it's written to list.xml would be the easiest way, but I can't seem to workout how exactly to do it.
I was hoping someone might know how to solve this problem, thanks in advanced.[/i]
Here is the current script;
Code: Select all
setlocal enabledelayedexpansion
del files.txt
echo ^<images^> >> files.txt
for /F "tokens=*" %%c in ('dir *.jpg;*.bmp /a-d /ogn /b') do (
echo ^<img^>%%c^<^/img^> >> list.xml
)
for /F "tokens=*" %%a in ('dir /ad /ogn /b /s') do (
for /F "tokens=*" %%b in ('dir "%%a\*.jpg;*.bmp" /a-d /ogn /b') do (
echo ^<img^>%%a^\%%b^<^/img^> >> list.xml
)
)
echo ^<^/images^> >> files.txt
endlocal
I'm not sure how to go about doing this, I was thinking that trimming the current directory path from %%a before it's written to list.xml would be the easiest way, but I can't seem to workout how exactly to do it.
I was hoping someone might know how to solve this problem, thanks in advanced.[/i]