|
Answer» I have a bat file that I want to kick off but then wait until a certain file gets DOWNLOADED to execute the remainder of the script. How can I check to see if a file exists on a recurring BASIS (i.e. loop) in the script without causing excessive resource usage on the machine (i.e. how can I leave some space between the checks).Assuming you have Windows XP, this might work:
Code: [Select]@echo off :1 if exist "%userprofile%\desktop\file.exe" ( echo The file is ready pause exit ) else ( goto :1 ) Is this something like what you need?that looks like what I need. how long does the 'pause' cause the program to wait before moving to the next command?I see your new to this...
Basically if the file exists, it will say on the screen "The file is ready" and "Press any key to continue. . ." This means it stops (forever) until you press any key. When you press any key, the program will close.okay then this is not what I need. Here's my flow.
1) I have an ftp script that runs and downloads files from a unix server to a windows server. 2) I then have processing that occurs via two scripts that are scheduled via a scheduling package my company uses. 3) The final step is an access database that I can't seem to get to work correctly when I try to run it scheduled (it just hangs, can't figure out why). however when I run it out of task scheduler it works fine.
so what I want to do is
1) create a file as the final step in one of the two scripts in #2 2) schedule the access database to run inside of a bat file which will kick off from task scheduler. inside that bat file would be a file check routine that does the following:
a) check to see if the file exists b) wait some period of time c) check to see if the file exists
and continue looping until the file does exist, then MOVE on to the next step in the code. is this doable?Is it doable..... What operating system are you using and how long do you want the BATCH file to wait for?
Also, if the batch file sees the file exists, you can start it with the batch file.
I actually have to go so someone will be along shortly to answer your question windows server 2003, and it could be anywhere from being there when the script starts to several hours. I think if the script could check every five minutes until it finds that the file exists that would be perfect.Code: [Select]@echo off :loop if not exist "c:\somefile" Goto Loop echo "finish" Ghostdog's code should work, but checks continuously and may be processor intensive for a batch file. The section of code to check for the file every 5 minutes (using PING as your timer) could be something like this:
Code: [Select]@echo off rem The first part of your code goes here :CheckForFile if exist "C:\Path\File.ext" goto FileExists ping -n 300 localhost >NUL goto :CheckForFile :FileExists rem The rest of your code goes here
|