Solved Batch file is only running through first sub-folder, not all

December 19, 2019 at 07:32:33
Specs: Windows 10
When I run my batch file it is suppose to:

1.Create sub folders if not created
2. Create paths to the sub-folders
3. Call a seperate BAT file and execute that file to run to connect to the database
4. When connected to the database, run a SQL file and print the output into CSV file and send those file to all sub-folders

When I run the file it only runs the for loop through the first sub-folder, then exits the batch file. I can't figure out whit it is only running through the first sub-folder and not the rest.
Here is my FOR LOOP:

FOR %%_ IN (
IF NOT EXIST %LOG_DIR%\%%_\ ( MD %LOG_DIR%\%%_\ )
echo=" here I am "
echo=Folder is: %%_
echo LOG_NM path and name ..... %LOG_DIR%\%%G\%LOG_NM%
CALL test_connection_%%_.bat


See More: Batch file is only running through first sub-folder, not all

Report •

December 19, 2019 at 19:31:55
✔ Best Answer
Don't know where %%G came from, or \%LOG_NM%. Maybe somewhere else in your code? A simple test of the main loop worked ok over here as long as the call-out to CALL test_connection_%%_.bat was disabled (since I don't know what it does nor where it is located). Seems like that missing link is probably the one to be analyzed. Put some echos into that, or turn its echo on to see what it's doing.

Report •
Related Solutions

Ask Question