Solved

File Exists and Loop

Posted on 2008-10-07
3
807 Views
Last Modified: 2010-04-21
I need a batch file that will check to see if a file exists and run additional code. If the file does not exist then it will just loop until complete. Does anyone know how to accomplish?
0
Comment
Question by:earngreen
3 Comments
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 22663222
Something like this (sleep.exe is in the Resource Kit; it's to prevent the machine from only waiting for the new file, depending on how fast you need to react to the arrival of the file, you can wait for longer)?

Windows Server 2003 Resource Kit Tools
http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en
@echo off
set WaitFile=C:\Temp\SomeFile.txt
:loop
sleep 1
if not exist "%WaitFile%" goto loop
REM Additional code below here ...

Open in new window

0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22663256
can also accomplish using
ping 127.0.0.1 -n 60 > nul

as opposed to sleep if you don't have the ability to download the reskit tools...the ping command is nearly the equivalent of a 60-second pause...
0
 

Author Closing Comment

by:earngreen
ID: 31503994
Thanks for the assistance
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question