I'm trying to assign subdirectory names to variables using FOR by saving CHDIR results to a temporary text document using a batch file
Batch file Input:
CD /d pathname
DIR /b /d >temp.txt
FINDSTR /b /n string pathname\temp.txt
ECHO find string results above
PAUSE
FOR /F "tokens=1-3" %%A IN ('FINDSTR /b string pathname\temp.txt') DO (
SET One=%%A
SET Two=%%B
SET Three=%%C
)
ECHO %One%
ECHO %Two%
ECHO %Three%
PAUSE
Command prompt output:
directory1
directory2
directory3
find string results above
Press any key to continue . . .
directory3
Echo is off.
Echo is off.
Press any key to continue . . .
The results from the initial FINDSTR should match the ECHO'd variables if they were assigned properly but only the final subdirectory name is being captured and the last two variables are not assigned.
how do I get each subdirectory to assign to a separate variable? Is there an easier way to accomplish this goal?