在Windows控制台上查找最近修改的文件

时间:2015-05-19 08:35:44

标签: cmd find windows-console

我需要检查cmd是否有最近修改过的特定文件(90分钟)。

在linux上,我的命令运行良好:

find /home/my_folder -type f -mmin -90 -name *.txt

在MS-DOS上,我找不到一种过滤修改时间的方法:

forfiles /P directory /S

1 个答案:

答案 0 :(得分:0)

您可以使用/ C参数:

/ C命令表示要为每个文件执行的命令。                         命令字符串应该用double包装                         引号。

                    The default command is "cmd /c echo @file".

                    The following variables can be used in the
                    command string:
                    @file    - returns the name of the file.
                    @fname   - returns the file name without
                               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 a file type is
                               a directory, and "FALSE" for files.
                    @fsize   - returns the size of the file in
                               bytes.
                    @fdate   - returns the last modified date of the
                               file.
                    @ftime   - returns the 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".

Ex:- forfiles /S /M *.txt /C "cmd /c echo @path @file @fdate @ftime"

认为这可能会有所帮助。您可以使用 forfiles /?查看更多帮助详情。