Batch file: Run command for every file of certain extension
Question:
I run a python command
python file.py inputfile.stl
but I want to expand it to input several files at a time. How would I make a windows batch file that when ran, will run a command for every *.stl
file in that directory. So for example it will run,
python file.py INPUTFILE1.stl
python file.py ANOTHERFILE.stl
python file.py BLAH.stl
....
Please note that the .stl files will have a different prefix.
Answers:
These topics can help: Batch script loop and batch file Copy files with certain extensions from multiple directories into one directory
So basically:
for %f in (*.stl) do python file.py %f
That will create a loop which executes all files in the directory with a .stl extension.
I run a python command
python file.py inputfile.stl
but I want to expand it to input several files at a time. How would I make a windows batch file that when ran, will run a command for every *.stl
file in that directory. So for example it will run,
python file.py INPUTFILE1.stl
python file.py ANOTHERFILE.stl
python file.py BLAH.stl
....
Please note that the .stl files will have a different prefix.
These topics can help: Batch script loop and batch file Copy files with certain extensions from multiple directories into one directory
So basically:
for %f in (*.stl) do python file.py %f
That will create a loop which executes all files in the directory with a .stl extension.