# process dos commands within txt file



## Code One (Jan 5, 2004)

ok i hate to flood the forum with my questions, but i found out that my first question will never get answered, because it is impossible.

so let me change my question:

Does anyone know if it is possible to process a txt file which holds dos commands, from a bat file?

for example
======================
test.txt

del C:\MYDOCU~1\hello.txt
======================
delfile.bat

for sake of limiting this post, the bat file would call for the txt, ?somehow?

see thats my question, how would i call for this txt file that holds dos commands, from my delfile.bat. is that even possible or should i just make another bat file and call that from the main bat file?

and if i shoudl just call another bat file from the main bat file, could someone show me the syntax for that, 

thanks

code one


----------



## Code One (Jan 5, 2004)

for example to make my objective more clear, just like when you make a txt file which hold FTP commands and then is processed with a bat file, can I do the same thing only this time with dos commands?


and if so, how?


----------



## mole (Aug 24, 1999)

I'm confused as to what you are asking, do you mean can you create a text file from DOS (command line in NT/2K/XP)?

Yes you can, type:

echo Hi, how are you. > c:\test.txt

Change > to >> to append more lines to the file.

If you mean how do you open a text file, you can do that too:

start c:\test.txt

Will open it in a Windows (assuming you are using Windows DOS or command prompt) application associated with *.txt files.

edit c:\test.txt

Will open the file in the command line text edito.


notepad c:\test.txt 

Will open the file in notepad.

...or did I gues totally wrong as to what you are asking?


----------



## coderitr (Oct 12, 2003)

The FTP interface allows specifying commands in a text file because the FTP client program is coded with that switch. The program reads the commands from the file and sends them individually to the FTP server. It sounds like what you're trying to do is continue the processing of a batch file using a dynamic text file. What you can do is name the file with a .bat extension and use the CALL statement from within your main batch program. The secondary batch file still must conform to proper syntax but you can put anything you want into it. You must name it .bat or .cmd under WinNT/2K/XP (either will work) or it won't run.


----------



## mole (Aug 24, 1999)

Based upon coderitr's reply, I may have a better idea of what Code One's original post was asking.

It is possible to read the contents of a text file line by line and send the string as a command line parameter(s) to a *.bat or any other file that can work with one for that matter. Your batch would have to be properly constructed to accept parameters and your text file would likewise have to be constructed to provide what is needed:

for /f %a in ('type myfile.txt') do mybatch.bat %a

(use %% for % with "for" inside a batch)

For other than *.bat files, one would similarly parse the output of such a text file line by line for a specific string using the "find" command:

for /f %a in ('type myfile.txt') do echo %a |find /I "mystring" >> {someoutput} 

Watch for any wraps in the lines above, they are all intended to be on one line. Also, again, with any command issued from the command prompt, you should check what is returned by issuing /? to get more help. You can even construct your batches to respond to the /? parameter so your will have a "help" section too by echoing instructions followed by the "pause" command.

Good luck, hope that helps.


----------

