Run multiple .bat from main .bat

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mwatsondhs
Posts: 9
Joined: 13 Jan 2015 09:51

Run multiple .bat from main .bat

#1 Post by mwatsondhs » 27 Jan 2015 14:30

Please forgive me if this is a stupid question, I'm new at this.

I have pieced together the code below and it works for one .pdf file.
But, it never gets to the second .bat file. Can someone please
explain to me what I'm doing wrong. I'll be honest I do not understand some
of this code, I mostly got it through here, but it works for sls316 and
does not execute sls312. Thank You.



main .bat:

Code: Select all

call rename_sls316.bat
call rename_sls312.bat



rename_sls316.bat :

Code: Select all

setlocal enabledelayedexpansion
FOR /F "delims=" %%G in ('dir SLS316*.pdf /a-d /b /od') do set "newest=%%~G"
copy "%newest%" "h:\BCS_Reports\Temp"

cd h:\BCS_Reports\Temp

dir /b | find "pdf" /i > temp.log
set tempvar=
for /f "tokens=1-2 delims=." /f %%A in (temp.log) do (
   rename_file.bat "%%A" %%B

   cd h:\BCS_Reports\Temp
   batch_remove_hyphens.bat
   getReportingPeriodDates.bat

   del temp.log
   cd h:
)

rename_sls312.bat :

Code: Select all

setlocal enabledelayedexpansion
FOR /F "delims=" %%G in ('dir SLS312*.pdf /a-d /b /od') do set "newest=%%~G"
copy "%newest%" "h:\BCS_Reports\Temp"

cd h:\BCS_Reports\Temp

dir /b | find "pdf" /i > temp.log
set tempvar=
for /f "tokens=1-2 delims=." /f %%A in (temp.log) do (
   rename_file.bat "%%A" %%B

   cd h:\BCS_Reports\Temp
   batch_remove_hyphens.bat
   getReportingPeriodDates.bat

   del temp.log
   cd h:
)

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Run multiple .bat from main .bat

#2 Post by Squashman » 27 Jan 2015 15:43

You need to CALL all your batch files.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Run multiple .bat from main .bat

#3 Post by Squashman » 27 Jan 2015 16:51

Why are you creating a directory listing first and then using that list in the FOR /F command? You can do it all with just a plain FOR command.

Also if you READ the help for the CD command you may want to note this. I warned you about it in your last thread.

Code: Select all

Use the /D switch to change current drive in addition to changing current
directory for a drive.


You have TOO MANY /F options in your FOR commands.

Post Reply