GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing ss64.com — Forfiles - Batch process multiple files command - Windows CMD FORFILES.exeSelect a file (or set of files) and execute a command on each file. Batch processing. Syntax
FORFILES [/p Path] [/m SrchMask] [/s] [/c Command] [/d [+ | -] {date | dd}]
Key
/p Path The Path to search (default=current folder)
/m SrchMask Select files matching the specified search mask
Wildcards are literal (non standard):
A mask of -m * will iterate all files (this is the default)
A mask of -m *.* will skip any extensionless filename.
/s Recurse into sub-folders
/C command The command to execute for each file.
Wrap the command string in double quotes.
Default = "cmd /c echo @file"
The Command variables listed below can also be used in the
command string.
/D date Select files with a last modified date greater than or
equal to (+), or less than or equal to (-),
the specified date, using the region specific date format.
The /? Help text will display the date format for your region
typically "MM/DD/yyyy" or "DD/MM/yyyy".
/D +dd Select files with a last modified date greater than or
equal to the current date plus "dd" days. (in the future)
/D -dd Select files with a last modified date less than or
equal to the current date minus "dd" days. (in the past)
A valid "dd" number of days can be any number in
the range of 0 to 32768. (89 years)
"+" is taken as the default sign if not specified.
Command Variables:
@file The name of the file.
@fname The file name without extension.
@ext Only the extension of the file.
@path Full path of the file.
@relpath Relative path of the file.
@isdir Returns "TRUE" if a file type is a directory,
and "FALSE" for files.
@fsize Size of the file in bytes.
@fdate Last modified date of the file.
@ftime Last modified time of the file.
To include special characters in the command line, use the hexadecimal code for the character in 0xHH format (ex. 0x09 for tab). Internal CMD.exe commands should be preceded with "cmd /c". Last modified time is taken to be midnight 00:00, so FORFILES /D +TodaysDate will find files created today. Last modified dates set in the future are not common but can happen when your computer clock date/time is changed e.g. due to daylight savings time. Early versions of FORFILES were supplied in the NT resource kit and used Unix style '-' parameters, (still supported for backwards compatibility) also the /D option accepted dates only in DDMMYYYYHHMN format. Bugs
Return values
ExamplesDelete the testfile if it is is 5 days old or older:
Find all .xlsx files that were last modified 30 days ago or older:
List the size of all .docx files:
Run a command against each text file newer than 1st Jan 2021:
“My parents tended to cook big batch food because there was always the possibility that other children would turn up with their carrier bag and shoes and we had to gently bring them out of their shells” ~ Jack Monroe Related commandsSyntax - Delete files older than N days Copyright © 1999-2026 SS64.com
Some rights reserved |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |