I was wondering if this was possible? I’m not familiar with using windows command line, but I have to use it for a project I’m working on. I have a a number of files, for which I need to perform a function for each. I’m used to working with python, but obviously this is a bit different, so I was hoping for some help.
Basically I need the for loop to iterate through 17 files in a folder, perform a function on each (that’s using the specific software I have here for the project) and then that will output a file with a unique name (the function normally requires me to state the output file name) I would suck it up and just do it by hand for each of the 17, but basically it’s creating a database of a file, and then comparing it to each of the 17. It needs to be iterated through several hundred times though. Using a for loop could save me days of work.
Suggestions?
The commandline interpreter does indeed have a FOR construct that you can use from the command prompt or from within a batch file.
For your purpose, you probably want something like:
Which will result in the name of each file with extension *.ext in the current directory being passed to my-function (which could, for example, be another .bat file).
The
(*.ext)part is the “filespec”, and is pretty flexible with how you specify sets of files. For example, you could do:To perform an operation in a different directory.
There are scores of options for the filespec and FOR in general. See
from the command prompt for more information.