I am writing a cmd script for XP. The script runs from a particular subdirectory and needs to determine the project directory it is in which is in the form of D:\Main\ProjectNum.
Once it does that it needs to list all the subdirectories of that project and create a string of the form:
"-psub1 -psub2 -psub3" (etc)
The problem is some of the subdirectories have commas in the name (e.g. "Pics,Photos,Etc").
When I run the code below it only grabs the subdirectory name up to the first comma.
How can I tell it to take the entire line and not just up to the comma?
======================
========================
Thanks,
JM
Once it does that it needs to list all the subdirectories of that project and create a string of the form:
"-psub1 -psub2 -psub3" (etc)
The problem is some of the subdirectories have commas in the name (e.g. "Pics,Photos,Etc").
When I run the code below it only grabs the subdirectory name up to the first comma.
How can I tell it to take the entire line and not just up to the comma?
======================
Code:
REM To find the project directory you are in:
for /f "tokens=1,2,3 delims=\ " %%a in ("%cd%") do set toppath=%%a\%%b\%%c
REM To list subdirectories:
dir /ad /b /s %toppath% > directories.txt
REM This is stripping the line after the comma
for /f %%D in ('type directories.txt') do (set pathlist=-p%%D %pathlist%)
echo %pathlist%
Thanks,
JM