MS Windows Batch Files – Doing Something to Each File in a Directory

Again, a note primarily for my reference…

To process each file in a directory using a batch file, the syntax would be

for %%f in (*.txt) do type %%f

From the command line it would be

for %f in (*.txt) do type %f

(and a reminder that

rename *.pdf B-*.pdf

really does rename all the PDF files by putting a “B” and a dash in front of each file)

Link to the microsoft.com web site:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true

This entry was posted in Technology and tagged , . Bookmark the permalink.