本帖最后由 77七 于 2024-4-24 00:51 编辑
回复 3# e20b1c222f0f
没想到好办法,使用了临时文件,代码指定了路径为 d:\ ,谨慎使用- @echo off
- rem 批处理保存为ansi编码格式
- cd /d "d:\"
- for /f "delims=" %%a in ('more +17 "%~f0"') do (
- if exist "%%~a" (
- cd.>"%%~a\$#.$#"
- for /f "delims=" %%d in ('2^>nul dir /b /s /ad "%%~a"') do (
- cd.>"%%d\$#.$#"
- )
- )
- )
- (for /f "delims=" %%d in ('dir /b /s /ad ^|sort /r') do (
- dir /b /s /a-d "%%d" |find "$#.$#" 1>nul || rd /s /q "%%d"
- )) 2>nul
- del /s /q "$#.$#" 1>nul
- pause & exit
- rem 以下存放需要保留的目录
- "D:\d\bbb"
- "D:\d\ccc"
复制代码
|