[英]Windows command line script for deleting files newer than a certain time, recursively
Can anyone help me with a windows command line script that recurses through a target directory and deletes files newer than the specified date and time stamp? 任何人都可以通过Windows命令行脚本来帮助我,该脚本可通过目标目录递归并删除比指定日期和时间戳新的文件?
I've tried the forfiles
command, but it doesn't allow me to specify the time , it only allows me to specify a date. 我已经尝试过
forfiles
命令,但是它不允许我指定时间 ,而仅允许我指定日期。
I think the only option is probably to use a FOR
statement, but I'm so new to the command line that I just can't figure it out. 我认为唯一的选择可能是使用
FOR
语句,但是我对命令行非常陌生,以至于无法弄清楚。
Save it as Delete_Files.bat And execute it as 将其另存为Delete_Files.bat并执行为
cmd> Delete_Files.bat MM-DD-YYYY cmd> Delete_Files.bat MM-DD-YYYY
for /f "tokens=*" %%a IN ('xcopy *.* /d:%1 /L /I null') do if exist "%%~nxa" del "%%~nxa"
Where do you specify the location to run the script against? 您在哪里指定运行脚本的位置? I ran the same one as above and it deleted everything in the same directory as where the Delete_files.bat was kept
我运行与上述相同的文件,并删除了与Delete_files.bat所在目录相同的目录中的所有文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.