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.

Asked By: Bijan

||

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.

Answered By: Gert-Jan Peeters
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.