Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wait for a command to terminate

Tags:

batch-file

I'm currently working on a batch file that should download files via their URL and them run formatting script on them however I don't know how to to delay the batch-file during downloading, however since it's a direct download the window doesn't stay open.
here's where I'm at :

START "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://www.oui.oui.fr/oui
MOVE C:\\Users\\*\\downloads\\*.csv %~dp0
EXIT

I would like to wait for the first line to finish before continuing. Thanks for your consideration

like image 677
Comte_Zero Avatar asked Nov 15 '25 02:11

Comte_Zero


1 Answers

From cmdline (cmd.exe) run start /? and you will find some help. There is a specific line in the help file for the /wait switch which reads:

WAIT        Start application and wait for it to terminate.

So simply start chrome with the /wait switch:

Start /wait "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://www.oui.oui.fr/oui

As per your comment, the above will not work. It is probably best to test if the file exists, chrome will have a .crdownload extension when still downloading. So let's test that the *.csv.crdownload does not exist.

start /wait "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://www.oui.oui.fr/oui
:hold
timeout 5
if /i not exist *.csv.crdownload (MOVE "C:\\Users\\*\\downloads\\*.csv" %~dp0) else ( goto :hold)
exit

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!