JSI Tip 1874. The Resource Kit ForFiles command.

Jerold Schulman

December 5, 1999

1 Min Read
ITPro Today logo

ForFiles is a command-line tool for selecting files for batch processing.

ForFiles enables you to run a command on/pass arguments to multiple files. It is simpler to use than the FOR command.

The syntax is:

ForFiles [-ppath] [-msearchmask] [-ccommand] [-dddmmyy] [-s] [-v] [-?]

Where:

-ppath

is the path to start searching.

-msearchmask

is the seach mask, where *.* is the default.

-ccommand

is a command to execute on each file. the default command is "cmd /c echo @file". Other variables are @path and @relpath

-dddmmyy

Files with a date >= ddmmyy are selected.

-s

Sub-directories are processed.

-v

Verbose output is selected.

?

Help.

Example:

ForFiles -pc: -s -m*.bat -c"cmd /c echo @file is a batch file"

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like