Amith
Amith

Reputation: 13

Executing .bat file in FOR loop

Edit: Brief Summary

I have number files in a directory, called crash0, crash1 etc. I want to run a .bat file for each of this with a command line like:

abc.bat crash0 > crash0.txt

How can I make another .bat file that loops over all the crashXX files calls abc.bat once for each one of them?

Original Question

Please find my situation below..

I have some files (number may vary each time) in a folder with its name starting with crash. That is crash0, crash1..etc. I want to provide these files as an input to a .bat file (let it be abc.bat) and then navigate the out put a corresponding text file. The command looks like abc.bat crash0 > crash0.txt. I have to do this to all the crash files in the folder. This abc.bat files actually converts the non-readable files to a readable format. So at the end I should have txt files like crash0.txt, crash1.txt.. etc for the corresponding crash files which i provided as the input. Can any one help with a .bat script to run this in cmd?? am new to .bat scripting.. thx in advance

Upvotes: 1

Views: 902

Answers (1)

Anton Tykhyy
Anton Tykhyy

Reputation: 20076

for %%i in (crash*) do @call abc.bat %%i > %%i.txt

Upvotes: 3

Related Questions