mbmart
asked on
Create batch file to loop through directories and run a program in each directory
I want to create an MS-DOS batch file that will loop through several directories then run the "ant" program in each of those directories.
Thank you for your help in advance.
Thank you for your help in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You could also use the "sweep.com" or PC-Plus provided "everydir.exe" utility:
http://www.pcplus.co.uk/tips/default.asp?pagetypeid=2&articleid=5528&subsectionid=390
========================== ========== ========== ========== ========== ========== =
EVERYDIR.EXE v1.0 (c) Ian Sharpe October 2000
Executes specified command line in every sub-folder.
Root folder defaults to current folder, or specify with /root:<folder path>
Eg:
everydir c:\somepath\somecommand parameter1 parameter2
everydir /root:C:\mydocu~1 c:\somepath\somecommand parameter1 parameter2
Note:
1 '/root:' must be the first parameter or it will become a parameter to
the target program
2 Sorry, but no long filenames. Use short filenames only.
3 For built-in DOS commands use everydir command /c <command>
========================== ========== ========== ========== ========== ==========
BFN,
fp.
http://www.pcplus.co.uk/tips/default.asp?pagetypeid=2&articleid=5528&subsectionid=390
==========================
EVERYDIR.EXE v1.0 (c) Ian Sharpe October 2000
Executes specified command line in every sub-folder.
Root folder defaults to current folder, or specify with /root:<folder path>
Eg:
everydir c:\somepath\somecommand parameter1 parameter2
everydir /root:C:\mydocu~1 c:\somepath\somecommand parameter1 parameter2
Note:
1 '/root:' must be the first parameter or it will become a parameter to
the target program
2 Sorry, but no long filenames. Use short filenames only.
3 For built-in DOS commands use everydir command /c <command>
==========================
BFN,
fp.
Just found this and found it immensely an immensely useful answer.
It wasnt my question but thank you experts.
It wasnt my question but thank you experts.
^^ mostly to brianadkins for the explaination of for
Definately A-Grade matherial though
Definately A-Grade matherial though
or you could simply do this:
------------ start batch file ------------
cls
cd\directory1
ant
cd\directory2
ant
cd\directory3
ant
exit
-------------- end batch ---------------