如果写成查找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
复制代码
|