首页 > 解决方案 > 使用 forfiles 获取上次访问日期

问题描述

我需要一些帮助来获取 forfiles 命令:

forfiles /S /M "*.exe" /C "cmd /C echo @Path @ISDIR @Fdate @Ftime @Fsize" >> Output.txt

标签: batch-fileforfiles

解决方案


The last access date is not something that FORFILES produces. It can be done in a .bat file script using PowerShell.

powershell -NoProfile -Command ^
    "Get-ChildItem -Recurse -File -Filter '*.exe' |" ^
        "ForEach-Object {'""{0}""" {1} {2} {3}' -f @($_.FullName, $_.PSIsContainer, $_.LastAccessTime, $_.Length) }"

Output:

"C:\src\t\renexe\bar.exe" False 2018-02-16 02:19:51 6
"C:\src\t\renexe\baz.exe" False 2018-02-16 02:19:51 6
"C:\src\t\renexe\foo.exe" False 2018-02-16 02:19:51 6

推荐阅读