标题: [日期时间] 请教批处理如何加个时间处理删除文件? [打印本页]
作者: gywl110 时间: 2021-7-30 10:27 标题: 请教批处理如何加个时间处理删除文件?
如果写成查找Image文件夹下的20天前的文件,如果都是连同目录一起删除
Image下会有2021-5 2021-6等多个文件夹- @echo off
-
- REM 通过注册表获取微信缓存路径
- for /f "tokens=2*" %%i in ('reg query "HKEY_CURRENT_USER\Software\Tencent\WeChat" /v FileSavePath') do (
- set "MyPath=%%j"
- )
- if /i "%MyPath%" equ "MyDocument:" (
- set "WeChatFolder=%userprofile%\Documents"
- ) else (
- set "WeChatFolder=%MyPath%"
- )
- if not exist "%WeChatFolder%" (
- goto :eof
- )
-
-
-
- REM 清理 Image 文件夹
- for /f "delims=" %%i in ('dir /b /s /ad "%WeChatFolder%\WeChat Files\" ^| findstr "\\FileStorage\\Image$"') do (
- pushd "%%i"
- echo 正在处理图片缓存 "%%i"
- for /d %%j in (*) do (
- rd /s /q "%%j"
- )
- popd
- )
-
- pause
复制代码
作者: qixiaobin0715 时间: 2021-7-30 10:33
http://bbs.bathome.net/thread-3334-1-1.html
作者: qixiaobin0715 时间: 2021-7-30 10:38
用forfiles
https://docs.microsoft.com/zh-cn ... s-commands/forfiles
作者: gywl110 时间: 2021-7-30 10:39
回复 2# qixiaobin0715 我用【方案3-1】 forfiles 在删除那里改成有点问题
作者: Batcher 时间: 2021-7-30 17:00
回复 4# gywl110
有点什么问题?
作者: gywl110 时间: 2021-8-2 11:55
本帖最后由 gywl110 于 2021-8-2 12:01 编辑
回复 5# Batcher 把 rd /s /q "%%j"改成forfiles /p 变量目录 /s /m *.* /d -20 /c "cmd /c echo del /f /q /a @path" 请问变量目录应该写成哪一个
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |