Reputation: 7
I have this code in my batch file:
@ECHO OFF
for /f %%a IN ('dir /b "D:\Main\Old\Pdf\Dom\*.pdf"') do (
fc D:\Main\Old\Pdf\Dom\%%~a D:\Main\Original\Pdf\Dom\%%~a >nul && (
echo Identical
) || (
generateReport.bat "D:\Main\Old\Pdf\Dom\%%~a" "D:\Main\Original\Pdf\Dom\%%~a" D:\OUTPUT\%%~a
)
)
for /f %%c IN ('dir /b "D:\Main\Old\Pdf\Int\*.pdf"') do (
fc D:\Main\Old\Pdf\Int\%%~c D:\Main\Original\Pdf\Int\%%~c >nul && (
echo Identical
) || (
generateReport.bat "D:\Main\Old\Pdf\Int\%%~c" "D:\Main\Original\Pdf\Int\%%~c" D:\OUTPUT\%%~c
)
)
This FIRST FOR STATEMENT loops for all the pdf files located in folder D:\Main\Old\Pdf\Dom and compare each of the file in folder D:\Main\Original\Pdf\Dom if they are have differences or none. If they do have, it calls my another batch file: generateReport.bat that generates pdf that contains the differences of that 2 files.
Now, the SECOND FOR STATEMENT do the same but loops for the different folder: D:\Main\Old\Pdf\Int. And compare files against folder D:\Main\Original\Pdf\Int.
Now, the problem is..... The first FOR loop works.. It outputs report.. But the second one not. Nothing happens.. No output report for the 2nd loop. I tried to have separate batch file for them. Both of them works.. But I want them in a single batch file. What am I missing here?
Upvotes: 0
Views: 49
Reputation: 70923
When a batch file is started from another batch file by directly invoking it, the execution is transfered to the called batch but does not return to the caller.
You need to use call generateReport.bat ....
. That way, when the called batch file ends, the execution continues in the caller
Upvotes: 2