/p :file path
/M: 特定檔名 *.*
/c :command
只用在 /c 內
@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. |
/d : [{+|-}][{<Date>|<Days>}] 日子 /d -01/01/2014 2014 一月一日前的 ,+是之後
------------set date format----------------
echo %DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%
------------7日前FILE------------------
forfiles /p C:\ /M *.log /c "cmd /c echo
@path @ftime" /D -7 > "C:\%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4% delete result log.
log"
------------刪除7日前FILE-----------
forfiles /p C:\ /M *.log /c "cmd /c echo
delete file : @path & Del @file" /D -7 > "C:\%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%
delete result log.log"