I'm not a big fan of batch files, most likely because I was exposed to bash scripts well before I ever started to delve into the former. Anyway, I didn't feel like switching to a bash prompt or writing a bash script today when faced with the challenge of iterating on all files of a certain type to perform the same operation on multiple files.
Therefore, I decided I wanted to do something directly from the Windows command line if possible, and shortly thereafter discovered a poorly designed yet inversely informative page on batch file commands that included the following information on the FOR command:
The syntax for this command is:
FOR variable in (set list) DO commandThe variable must be in the form of one alphabetic character preceeded [sic] by
%%; e.g.,%%v.However, if you run the
FORcommand outside of a batch file, simply from the system prompt, just use a single%in the variable name.
I gave it a shot, and it did what I needed. Here's an example for completion's sake:
FOR %Z IN (*.pl) DO perl %Z
I figured I'd jot it down here at my blog in case the need presents itself in the future (or someone else finds it useful).
Comments
No one has added any comments.
Post Comments
If you feel like commenting on the above item, use the form below. Your email address will be used for personal contact reasons only, and will not be shown on this website.