Board logo

标题: [文件操作] 【已解决】如何制作一个自动处理微信后台保存过的所有文件和图片和缓存 [打印本页]

作者: 朱科技    时间: 2022-12-4 19:53     标题: 【已解决】如何制作一个自动处理微信后台保存过的所有文件和图片和缓存

本帖最后由 朱科技 于 2022-12-28 10:36 编辑

怎么写代码呢
作者: Batcher    时间: 2022-12-4 19:55

回复 1# 朱科技


    请说说具体怎么处理
作者: 朱科技    时间: 2022-12-4 21:33

回复 2# Batcher


    删除处理
作者: 77七    时间: 2022-12-4 22:13

找到各自的文件夹,写个删除命令就行了
作者: ygqiang    时间: 2022-12-5 05:43

回复 1# 朱科技
  1. @echo off
  2. title deldel
  3. ping 0 -n 1 >nul 2>nul
  4. if "%1" == "h" goto begin
  5. mshta vbscript:createobject^("wscript.shell"^).run^("%~fs0 h %1",0^)^(window.close^)&&exit
  6. :begin
  7. rem 下边开始写批处代码了
  8. echo 删除不确定目录名下-固定路径-固定某个目录下的所有文件和文件夹
  9. echo 比如c:\Users\用户名\AppData\Roaming\kingsoft\office6\backup,其中用户名有很多,不确定具体名称
  10. ----------------------------------------------------
  11. cls
  12. set "filesname=FileStorage\Cache"
  13. ::指定文件夹后缀
  14. set "dird=%userprofile%\Documents\WeChat Files"
  15. ::指定文件夹前缀
  16. for /f "delims=" %%a in ('dir /ad /b "%dird%"') do (
  17. if exist "%dird%\%%a\%filesname%" (
  18. 1start "" "%dird%\%%a\%filesname%"
  19. 1pause
  20. del /s /f /q "%dird%\%%a\%filesname%\*.*" 2>nul & cls
  21. )
  22. if exist "%dird%\%%a\%filesname%" (
  23. for /f "delims=" %%b in ('dir /ad /b /s "%dird%\%%a\%filesname%"^|sort /r') do (rd "%%b" /s /q & cls)
  24. )
  25. )
  26. ----------------------------------------------------
  27. cls
  28. set "filesname=FileStorage\Image"
  29. ::指定文件夹后缀
  30. set "dird=%userprofile%\Documents\WeChat Files"
  31. ::指定文件夹前缀
  32. for /f "delims=" %%a in ('dir /ad /b "%dird%"') do (
  33. if exist "%dird%\%%a\%filesname%" (
  34. 1start "" "%dird%\%%a\%filesname%"
  35. 1pause
  36. del /s /f /q "%dird%\%%a\%filesname%\*.*" 2>nul & cls
  37. )
  38. if exist "%dird%\%%a\%filesname%" (
  39. for /f "delims=" %%b in ('dir /ad /b /s "%dird%\%%a\%filesname%"^|sort /r') do (rd "%%b" /s /q & cls)
  40. )
  41. )
  42. ----------------------------------------------------
  43. cls
  44. set "filesname=FileStorage\Video"
  45. ::指定文件夹后缀
  46. set "dird=%userprofile%\Documents\WeChat Files"
  47. ::指定文件夹前缀
  48. for /f "delims=" %%a in ('dir /ad /b "%dird%"') do (
  49. if exist "%dird%\%%a\%filesname%" (
  50. 1start "" "%dird%\%%a\%filesname%"
  51. 1pause
  52. del /s /f /q "%dird%\%%a\%filesname%\*.*" 2>nul & cls
  53. )
  54. if exist "%dird%\%%a\%filesname%" (
  55. for /f "delims=" %%b in ('dir /ad /b /s "%dird%\%%a\%filesname%"^|sort /r') do (rd "%%b" /s /q & cls)
  56. )
  57. )
  58. --------------------------------------------------------------------------------------------------------
  59. --------------------------------------------------------------------------------------------------------
  60. cls
  61. set "dird=%userprofile%\Documents"
  62. ::指定文件夹
  63. if exist "%dird%" (
  64. 1start "" "%dird%"
  65. 1pause
  66. del /s /f /q "%dird%\*.*" 2>nul & cls
  67. for /f "delims=" %%a in ('dir /ad /b "%dird%"') do (
  68. for /f "delims=" %%b in ('dir /ad /b /s "%dird%"^|sort /r') do (rd "%%b" /s /q & cls)
  69. )
  70. )
  71. --------------------------------------------------------------------------------------------------------
  72. --------------------------------------------------------------------------------------------------------
  73. cls
  74. set "dird=C:\Users\Public\Documents"
  75. ::指定文件夹
  76. if exist "%dird%" (
  77. 1start "" "%dird%"
  78. 1pause
  79. del /s /f /q "%dird%\*.*" 2>nul & cls
  80. for /f "delims=" %%a in ('dir /ad /b "%dird%"') do (
  81. for /f "delims=" %%b in ('dir /ad /b /s "%dird%"^|sort /r') do (rd "%%b" /s /q & cls)
  82. )
  83. )
  84. --------------------------------------------------------------------------------------------------------
  85. --------------------------------------------------------------------------------------------------------
  86. cls
  87. set "dird=%userprofile%\AppData\Roaming\Tencent"
  88. ::指定文件夹
  89. if exist "%dird%" (
  90. 1start "" "%dird%"
  91. 1pause
  92. del /s /f /q "%dird%\*.*" 2>nul & cls
  93. for /f "delims=" %%a in ('dir /ad /b "%dird%"') do (
  94. for /f "delims=" %%b in ('dir /ad /b /s "%dird%"^|sort /r') do (rd "%%b" /s /q & cls)
  95. )
  96. )
  97. exit
复制代码

作者: Batcher    时间: 2022-12-5 09:37

回复 3# 朱科技


批处理升级版清理微信电脑版的图片和视频文件
https://mp.weixin.qq.com/s/tl-tUaZ86RAbl51gh1Naog

批处理清理微信电脑版的图片和视频文件
https://mp.weixin.qq.com/s/cTXBsoJp3-3sxrZfvkMaDg

试试能否成功
作者: 朱科技    时间: 2022-12-5 20:07

回复 5# ygqiang

这么长命令啊,辛苦了
作者: 朱科技    时间: 2022-12-5 20:08

回复 6# Batcher

我看了下,眼睛都花了
作者: ygqiang    时间: 2022-12-28 10:54

本帖最后由 ygqiang 于 2022-12-28 11:17 编辑

回复 8# 朱科技
  1. @echo off
  2. REM 通过注册表获取微信缓存路径
  3. for /f "tokens=2*" %%i in ('reg query "HKEY_CURRENT_USER\Software\Tencent\WeChat" /v FileSavePath') do (
  4.     set "MyPath=%%j"
  5. )
  6. if /i "%MyPath%" equ "MyDocument:" (
  7.     set "WeChatFolder=%userprofile%\Documents"
  8. ) else (
  9.     set "WeChatFolder=%MyPath:~0,-1%"
  10. )
  11. if not exist "%WeChatFolder%" (
  12.     goto :eof
  13. )
  14. echo —我的文档—:%WeChatFolder%
  15. 1pause
  16. cls
  17. REM 清理 Image 文件夹
  18. for /f "delims=" %%i in ('dir /b /s /ad "%WeChatFolder%\WeChat Files\" ^| findstr "\\FileStorage\\Image$"') do (
  19.     pushd "%%i"
  20.     echo 正在处理文件夹 "%%i"
  21.     for /d %%j in (*) do (
  22.         rd /s /q "%%j"
  23.     )
  24.     popd
  25. )
  26. REM 清理 Video 文件夹
  27. for /f "delims=" %%i in ('dir /b /s /ad "%WeChatFolder%\WeChat Files\" ^| findstr "\\FileStorage\\Video$"') do (
  28.     pushd "%%i"
  29.     echo 正在处理文件夹 "%%i"
  30.     for /d %%j in (*) do (
  31.         rd /s /q "%%j"
  32.     )
  33.     popd
  34. )
  35. cls
  36. echo %WeChatFolder%\WeChat Files
  37. 1pause
  38. rd /s /q "%WeChatFolder%\WeChat Files"
  39. 1pause
  40. cls
  41. echo 清空 —我的文档— (%WeChatFolder%)
  42. 1pause
  43. if exist "%WeChatFolder%" (
  44. 1start "" "%WeChatFolder%"
  45. 1pause
  46. del /s /f /q "%WeChatFolder%\*.*" 2>nul & cls
  47. for /f "delims=" %%a in ('dir /ad /b "%WeChatFolder%"') do (
  48. for /f "delims=" %%b in ('dir /ad /b /s "%WeChatFolder%"^|sort /r') do (rd "%%b" /s /q & cls)
  49. )
  50. )
  51. exit
复制代码





欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2