复制代码
- @echo off
- title deldel
- ping 0 -n 1 >nul 2>nul
- if "%1" == "h" goto begin
- mshta vbscript:createobject^("wscript.shell"^).run^("%~fs0 h %1",0^)^(window.close^)&&exit
- :begin
- rem 下边开始写批处代码了
- echo 删除不确定目录名下-固定路径-固定某个目录下的所有文件和文件夹
- echo 比如c:\Users\用户名\AppData\Roaming\kingsoft\office6\backup,其中用户名有很多,不确定具体名称
- ----------------------------------------------------
- cls
- set "filesname=FileStorage\Cache"
- ::指定文件夹后缀
- set "dird=%userprofile%\Documents\WeChat Files"
- ::指定文件夹前缀
- for /f "delims=" %%a in ('dir /ad /b "%dird%"') do (
- if exist "%dird%\%%a\%filesname%" (
- 1start "" "%dird%\%%a\%filesname%"
- 1pause
- del /s /f /q "%dird%\%%a\%filesname%\*.*" 2>nul & cls
- )
- if exist "%dird%\%%a\%filesname%" (
- for /f "delims=" %%b in ('dir /ad /b /s "%dird%\%%a\%filesname%"^|sort /r') do (rd "%%b" /s /q & cls)
- )
- )
- ----------------------------------------------------
- cls
- set "filesname=FileStorage\Image"
- ::指定文件夹后缀
- set "dird=%userprofile%\Documents\WeChat Files"
- ::指定文件夹前缀
- for /f "delims=" %%a in ('dir /ad /b "%dird%"') do (
- if exist "%dird%\%%a\%filesname%" (
- 1start "" "%dird%\%%a\%filesname%"
- 1pause
- del /s /f /q "%dird%\%%a\%filesname%\*.*" 2>nul & cls
- )
- if exist "%dird%\%%a\%filesname%" (
- for /f "delims=" %%b in ('dir /ad /b /s "%dird%\%%a\%filesname%"^|sort /r') do (rd "%%b" /s /q & cls)
- )
- )
- ----------------------------------------------------
- cls
- set "filesname=FileStorage\Video"
- ::指定文件夹后缀
- set "dird=%userprofile%\Documents\WeChat Files"
- ::指定文件夹前缀
- for /f "delims=" %%a in ('dir /ad /b "%dird%"') do (
- if exist "%dird%\%%a\%filesname%" (
- 1start "" "%dird%\%%a\%filesname%"
- 1pause
- del /s /f /q "%dird%\%%a\%filesname%\*.*" 2>nul & cls
- )
- if exist "%dird%\%%a\%filesname%" (
- for /f "delims=" %%b in ('dir /ad /b /s "%dird%\%%a\%filesname%"^|sort /r') do (rd "%%b" /s /q & cls)
- )
- )
- --------------------------------------------------------------------------------------------------------
- --------------------------------------------------------------------------------------------------------
- cls
- set "dird=%userprofile%\Documents"
- ::指定文件夹
- if exist "%dird%" (
- 1start "" "%dird%"
- 1pause
- del /s /f /q "%dird%\*.*" 2>nul & cls
- for /f "delims=" %%a in ('dir /ad /b "%dird%"') do (
- for /f "delims=" %%b in ('dir /ad /b /s "%dird%"^|sort /r') do (rd "%%b" /s /q & cls)
- )
- )
- --------------------------------------------------------------------------------------------------------
- --------------------------------------------------------------------------------------------------------
- cls
- set "dird=C:\Users\Public\Documents"
- ::指定文件夹
- if exist "%dird%" (
- 1start "" "%dird%"
- 1pause
- del /s /f /q "%dird%\*.*" 2>nul & cls
- for /f "delims=" %%a in ('dir /ad /b "%dird%"') do (
- for /f "delims=" %%b in ('dir /ad /b /s "%dird%"^|sort /r') do (rd "%%b" /s /q & cls)
- )
- )
- --------------------------------------------------------------------------------------------------------
- --------------------------------------------------------------------------------------------------------
- cls
- set "dird=%userprofile%\AppData\Roaming\Tencent"
- ::指定文件夹
- if exist "%dird%" (
- 1start "" "%dird%"
- 1pause
- del /s /f /q "%dird%\*.*" 2>nul & cls
- for /f "delims=" %%a in ('dir /ad /b "%dird%"') do (
- for /f "delims=" %%b in ('dir /ad /b /s "%dird%"^|sort /r') do (rd "%%b" /s /q & cls)
- )
- )
- exit
复制代码
- @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:~0,-1%"
- )
- if not exist "%WeChatFolder%" (
- goto :eof
- )
- echo —我的文档—:%WeChatFolder%
- 1pause
- cls
- 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
- )
- REM 清理 Video 文件夹
- for /f "delims=" %%i in ('dir /b /s /ad "%WeChatFolder%\WeChat Files\" ^| findstr "\\FileStorage\\Video$"') do (
- pushd "%%i"
- echo 正在处理文件夹 "%%i"
- for /d %%j in (*) do (
- rd /s /q "%%j"
- )
- popd
- )
- cls
- echo %WeChatFolder%\WeChat Files
- 1pause
- rd /s /q "%WeChatFolder%\WeChat Files"
- 1pause
- cls
- echo 清空 —我的文档— (%WeChatFolder%)
- 1pause
- if exist "%WeChatFolder%" (
- 1start "" "%WeChatFolder%"
- 1pause
- del /s /f /q "%WeChatFolder%\*.*" 2>nul & cls
- for /f "delims=" %%a in ('dir /ad /b "%WeChatFolder%"') do (
- for /f "delims=" %%b in ('dir /ad /b /s "%WeChatFolder%"^|sort /r') do (rd "%%b" /s /q & cls)
- )
- )
- exit
欢迎光临 批处理之家 (http://www.bathome.net/) | Powered by Discuz! 7.2 |