text stringlengths 0 4.23k |
|---|
forfiles |
Selects and runs a command on a file or set of files. This command is most commonly used in batch files. |
Syntax |
forfiles [/P pathname] [/M searchmask] [/S] [/C command] [/D [+ | -] [{<date> | <days>}]] |
Parameters |
Parameter |
Description |
/P <pathname> |
Specifies the path from which to start the search. By default, searching starts in the current working directory. |
/M <searchmask> |
Searches files according to the specified search mask. The default searchmask is *. |
/S |
Instructs the forfiles command to search in subdirectories recursively. |
/C <command> |
Runs the specified command on each file. Command strings should be wrapped in double quotes. The default command is "cmd /c echo @file". |
/D [{+\|-}][{<date> | <days>}] |
Selects files with a last modified date within the specified time frame:Selects files with a last modified date later than or equal to (+) or earlier than or equal to (-) the specified date, where date is in the format MM/DD/YYYY.Selects files with a last modified date later than or equal to (+) the current date plus the number of days specified, or earlier than or equal to (-) the current date minus the number of days specified.Valid values for days include any number in the range 0–32,768. If no sign is specified, + is used by default. |
/? |
Displays the help text in the cmd window. |
<pathname> |
<searchmask> |
* |
<command> |
"cmd /c echo @file" |
[{+\|-}][{<date> | <days>}] |
Remarks |
The forfiles /S command is similar to dir /S. |
forfiles /S |
dir /S |
You can use the following variables in the command string as specified by the /C command-line option: |
Variable |
Description |
@FILE |
File name. |
@FNAME |
File name without extension. |
@EXT |
File name extension. |
@PATH |
Full path of the file. |
@RELPATH |
Relative path of the file. |
@ISDIR |
Evaluates to TRUE if a file type is a directory. Otherwise, this variable evaluates to FALSE. |
@FSIZE |
File size, in bytes. |
@FDATE |
Last modified date stamp on the file. |
@FTIME |
Last modified time stamp on the file. |
The forfiles command lets you run a command on or pass arguments to multiple files. For example, you could run the type command on all files in a tree with the .txt file name extension. Or you could execute every batch file (*.bat) on drive C, with the file name Myinput.txt as the first argument. |
This command can: |
Select files by an absolute date or a relative date by using the /d parameter. |
Build an archive tree of files by using variables such as @FSIZE and @FDATE. |
Differentiate files from directories by using the @ISDIR variable. |
Include special characters in the command line by using the hexadecimal code for the character, in 0xHH format (for example, 0x09 for a tab). |
This command works by implementing the recurse subdirectories flag on tools that are designed to process only a single file. |
recurse subdirectories |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.