forfiles/p e:/dbbackup/diff/s/M * */d-14/c "cmd/c del @file"
Forfiles:
The path specified by/p
/s includes sub-directories
/M Lookup filename Mask
/d Specifies the date, with an absolute date and a relative date, where-7 refers to the current date 7 days ago
The command line run by/C represents the command executed for each file. The command string should
Enclose in double quotation marks.
The default command is "cmd/c echo @file". The following variables
can be used in the command string:
@file-Returns the file name.
@fname-Returns the file name without an extension.
@ext-Returns only the extension of the file.
@path-Returns the full path of the file.
@relpath-Returns the relative path of the file.
@isdir-Returns "TRUE" if the file type is a directory;
if it is a file, return "FALSE".
@fsize-Returns the file size in bytes.
@fdate-Returns the date the file was last modified.
@ftime-Returns the time the file was last modified.
Example
To list all the batch files on drive C:, type:
forfiles/p c://s/m*.bat/c "cmd/c Echo @file is a batch file"
To list all directories on drive C:, type:
forfiles/p c://s/m*.*/C "cmd/c if @isdir ==true echo @file is a directory"
To list all files on drive C: With more than 100 days of existence, type:
forfiles/p c://s/m*.*/dt-100/c "cmd/c echo @file:d ate >=
To list drive C: All files that were created before January 1, 1993, and for files that have dates earlier than January 1, 1993 that show "file is quite old!", type:
forfiles/p c://s/m*.*/dt-01011993/c "cmd/c Echo @file is quite old!"
To list the extensions for all files on drive C: In column format, type:
forfiles/p c://s/m*.*/C "cmd/c echo extension of @file is [email protected]' with:
To list all the batch files on drive C:, type:
forfiles/p c://s/m *.bat/c "cmd/c Echo @file is a batch file"
To list all directories on drive C:, type:
forfiles/p c://s/m */C "cmd/c if @isdir ==true echo @file is a directory"
To list all files on drive C: With more than 100 days of existence, type:
forfiles/p c://s/m */d t-100/c "cmd/c echo @file:d ate >=
To list drive C: All files that were created before January 1, 1993, and for files that have dates earlier than January 1, 1993 that show "file is quite old!", type:
forfiles/p c://s/m */d t-01011993/c "cmd/c Echo @file is quite old!"
To list the extensions for all files on drive C: In column format, type:
forfiles/p c://s/m*.*/C "cmd/c echo extension of @file is [email protected]"
DOS Command Forfiles