![](/img/trans.png)
[英]batch file to set attrib +r on all .docx files created or modified in the last days
[英]Using batch file to list files created or modified in the last 7days
我正在尝试创建一个批处理文件,该文件将查看文件夹及其子文件夹并列出过去 7 天内创建或修改的所有文件。 我只想知道符合条件的文件,而不是文件夹。
我玩过 DIR 命令,但无论我做什么,它似乎总是列出所有内容。
我在 2017 年的 Stackoverflow 中发现了这段代码,看起来很有希望(我玩过 DIR 开关),但它似乎没有创建任何 output。
我对批处理文件及其命令的了解非常有限。 运行 Windows 10。
TIA
奈杰尔
@echo off
setlocal EnableDelayedExpansion
echo Input the date(dd/mm/yyyy):
set /p compDate=
for /F "tokens=1-3 delims=/" %%a in ("%compDate%") do set compDate=%%c%%b%%a
echo Input the directory:
set /p directory=
SET Exit=%UserProfile%\Desktop\test.txt
pushd "%directory%"
(for /F "tokens=1-5*" %%a in ('dir /s /od /tc /a-d') do (
set "fileDate=%%a"
if "!fileDate:~2,1!!fileDate:~5,1!" equ "//" (
for /F "tokens=1-3 delims=/" %%x in ("!fileDate!") do set fileDate=%%z%%y%%x
if !fileDate! geq %compDate% (
set "fileSize= %%e"
echo %%a %%b %%c %%d !fileSize:~-16! %%f
)
)
)) > %Exit%
popd
如果我误解了你,你可以 go 在这里深入探讨
forfiles /P FOLDER_PATH\ /S /D -7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.