Solved

File Exists and Loop

Posted on 2008-10-07
3
819 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 84

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

737 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