Solved

File Exists and Loop

Posted on 2008-10-07
3
795 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now