View Full Version : Script doesn't wait

29.06.2016, 11:27 AM
I have this script:

call %~dp0\IrfanViewPortable\IrfanViewPortable.exe %~dp0\pictures\*.jpg /convert="%~dp0\Output\temp\%INPUT% %HASH%.jpg"
call %~dp0\7Zip\7z.exe a %~dp0\Output\%INPUT%.zip %~dp0\Output\temp\*
@RD /S /Q "%~dp0\Output\temp"

I want to rename all pictures in the folder "pictures" and copy them to "temp". After renaming 7zip should zip the renamed files. But 7zip starts zipping before irfanview ended the renaming. So just a few pictures get zipped.

I also tried "start \wait" -> no difference.
I added "ping -n 2 > nul" with various times -> a few more pictures get zipped but not all

How does the Batch wait until irfanview is ready with coping all pictures?


Bhikkhu Pesala
29.06.2016, 08:21 PM
How about using a Pause cmd and pressing any key to continue with the archiving operation?

29.06.2016, 11:26 PM
How about using a Pause cmd and pressing any key to continue with the archiving operation?

That would be a possibility. But I prefer a solution which works without human interaction. The target group of this project needs a tool which is as easy as possible.

29.06.2016, 11:38 PM
I tried the same program again (without Pause) and its working great... The zipping waits until irfanview finished the conversion. I'll see, if the problem occurs again.

30.06.2016, 08:27 PM
Are you sure you did exactly the same thing when you tried it the second time? We have discussed this in the past but I am unable to find the thread I was looking for because it was a long time ago.

The issue is about whether or not the script waits for Irfanview to close before continuing. There are differences between using the command "Start" the command "Call" or no command at all at the beginning of the line where you want to launch an external program. I seem to recall that with no command the script always waits for the external program to terminate, whereas with "Start" it always continues without waiting. With "Call" I think it behaves differently in a Command Prompt window to how it does in a Batch file. I may have got this a bit mixed up though. I have not used Command Prompt scripts for some time, preferring to use Visual Basic scripts instead.

11.06.2019, 08:40 PM
I have had this problem with Windows 10. The solution was that start will not wait unless you are launching a 64 bit program. Try the 64 bit version of Irfanview.