2
1
I have a batch script I wrote called "joiner.bat." It needs to run inside each of 730 sub-directories of a folder. The joiner.bat file has already been copied into each of the sub-folders, it just needs to run in each. I tried this, but it doesn't work:
for %f in (*) do joiner.bat %f
I tried that command outside of a batch file just on the command prompt but it did nothing. I need the command to go into a folder, run the command, go back to the previous folder, into the next, run the command, and so on.
Unfortunately that didn't work. After that command failed, I decided to copy your code and joiner.bat into one and to see if that would help and it didn't. This is the entire bat file:
`for /d %%a in (*) do ( cd %%a copy /b *.xml newfile.xml
@echo off SET "CDIR=%~dp0" SET "CDIR=%CDIR:~0,-1%" FOR %%i IN ("%CDIR%") DO SET "PARENTFOLDERNAME=%%~nxi"
move newfile.xml "C:\users\lacroixja01\desktop\test%PARENTFOLDERNAME%.xml" )` – jlacroix82 – 2012-04-04T15:31:37.560
Windows batch doesn't deal well with modifying variable in a loop. Try adding this to the top of the batch file: setlocal ENABLEDELAYEDEXPANSION – uSlackr – 2012-04-04T15:56:41.353
I posted modified code to my answer. its not tested! – uSlackr – 2012-04-04T16:07:40.497
This did it:
`for /d %%a in (*) do ( pushd %%a
call joiner.bat
popd )` – jlacroix82 – 2012-04-04T16:39:53.077