user2272116
user2272116

Reputation: 21

How to make a batch program wait until it detects a file

So here is what I have

:a
IF EXIST D:\ (
goto copy
) ELSE (
goto wait
)

:wait
timeout /t 300
goto a

:copy
xcopy "D:\photos" "C:\Photos From Cam"
exit

but I'm not very fond of this becuase that means it is always looping, except for the 5 minute pause, and I would like a way to do this where it doesnt run any code until it detects the files. Is this possible?

Upvotes: 2

Views: 68

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202222

I do not think there's a better solution using just shell, than the one you already have.

You would have to use some external tools
For example refer to question Windows: File Monitoring Script (Batch/VBS).

Upvotes: 1

Related Questions