Computer Hope
Microsoft => Microsoft DOS => Topic started by: akpolarsmurf on September 15, 2006, 12:36:34 PM
-
Hi everyone,
I'm trying to write a batch file that will be called with the scheduled tasks function of Windows XP. In this batch file, I want to be able to run any batch file found in a certain directory. For example:
call e:\test\*.bat
but for some reason I can't get this to work. Is there a method of executing multiple batch files without knowing what the names of those files will be?
-
I cannot find any info on using a wildcard with Call. Have found one site which indicates that the filename is definitely required.
Here (http://www.computerhope.com/call.htm#03) is the C.H. Call site - note that the filename is not bracketed indicating that it is mandatory.
Good luck
-
You can't use a wildcard in a call, the cmd processor is just not that sophisticated. You can however create a loop to do a call over the collection of batch files:
@echo off
for /f "tokens=* delims=" %%i in ('dir /b e:\test\*.bat') do call "%%i"
This batch file needs to be in same directory as your batch files. If not, you may need to use the /s switch. You also have some limited options for sorting the files. Check out dir /? for details.
8-)
-
Excellent! I was even able to put in a provision that after each bat file was run, it would be renamed to .BAK so it would not be run again. Thanks for the help!
-
I was even able to put in a provision that after each bat file was run, it would be renamed to .BAK so it would not be run again.
but as the FOR cycle steps through all the .bat files in e:\test there should be no risk of running any of them again, if I understand how FOR works.
How did you manage to rename *.bat to *.bak anyway ?
I mean, how/where can you do it ?
After the
do call "%%i"
it shouldn't work.