Name: ld123 Date: February 1, 2008 at 00:21:46 Pacific Subject: Batch to check folder size OS: XP SP2 CPU/Ram: 2gb Model/Manufacturer: HP Pav dv6000
Comment:
I am hoping someone can help with this. I have three bat files. The first is set to run with a scheduler, and it calls the second and third bat file. What I would like is to poll a certain folder every 60 seconds, and if it is empty, then call the first bat. Once the first bat runs, it will call the 2nd and 3rd, then the poller will start again after they complete.
If there is something still in the folder, have the "poller" sleep for 60 seconds, then poll again until it is empty. Thanks in advance.
2 questions, first, if I wanted to reverse this and run a batch when it sees new folders, would I set the errorlevel to 0?
Second, how would I set the batch above to quit and exit after it runs the called batch file? Meaning, the batch will poll a folder to see when it is empty. Once it sees that it is empty, it will call the first.bat, run it, and then stop and exit all together.
"if I wanted to reverse this and run a batch when it sees new folders, would I set the errorlevel to 0?"
No. This is a classic gotcha. A test for errorlevel means:
if errorlevel X [OR MORE] !]
so 0 will always be true. To reverse the logic, use:
if not errorlevel 1
"the batch will poll a folder to see when it is empty. Once it sees that it is empty, it will call the first.bat, run it, and then stop and exit all together."
Simplest way is not CALL but just run the next bat. That way it never returns. Like this:
Let me be the first to say, you the man. This works perfectly. Can you recommend a good reference site? I know the help command, but just looking at the set /? output hurts my brain.
Oh, almost forgot. If I open a window from the command line, "start c:\folder", is there a way to close it via command line? If not, no biggie. When in doubt, format.
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE