Ok can anyone help me understand the FOR AND DO cmds for Batch files and how to pass parameters between batch fies? thanks.
Posted by Chanie (Member # 9544) on :
A parameter for a batch file is passed on the command line after a space. Like let's say you wanted to pass the parameter "hello" for a batch program called Blayne.bat. On the command line, you would type: Blayne hello
In the batch file, you would reference the argument with %1. The second argument is %2, etc. Such as "echo %1."
I don't understand the first part of the question.
You'd probably be best off doing something like googling "DOS batch files."
Posted by King of Men (Member # 6684) on :
It would be helpful if you were to confirm that you are indeed working on DOS, or generally what operating system you are under.
Posted by Mike (Member # 55) on :
My advice? Install cygwin and use bash.
Posted by Blayne Bradley (Member # 8565) on :
DOS prompt.
Posted by Avin (Member # 7751) on :
Type > for /?
at a prompt and it will spit out for you a help page that documents everything you need to know.
Here's an example of a for loop I made in a batch file I use at work:
for %%I in (%UPGROOT%\5100\*) do echo DELETEFILE "..\5100\%%~nxI"; >> %S5SCRIPT%
This will enumerate all the files in the directory specified by %UPGROOT%\5100\ (where %UPGROOT% is a variable defined elsewhere), and write a line to a file (specified by %S5SCRIPT%) of the form
DELETEFILE "..\5100\filename";
(note that the filename then will NOT include the path the file was found at)
Posted by TomDavidson (Member # 124) on :
Note that you should almost never write batch files nowadays unless you have to. WMI and PowerShell are better alternatives.