保存为ansi编码的bat,放到当前目录下运行
使用前先测试,测试前先备份- @echo off
- for /d %%a in (*) do (
- setlocal
- for /d %%b in ("%%a\*") do set hasfolder=1
- if not defined hasfolder (
- for %%c in ("%%a\*") do (
- set file=%%~fc
- set /a n+=1
- )
- setlocal enabledelayedexpansion
- if !n! == 1 (endlocal&call :aaa) else endlocal
- )
- endlocal
- )
- echo,&pause&exit/b
-
- :aaa
- if defined m set "p=(%m%)"
- for %%z in ("%file%") do (
- if not exist "%%~nz%p%%%~xz" (
- move "%%~z" ".\%%~nz%p%%%~xz" && rmdir "%%~dpz") else (
- set /a m+=1&goto :aaa
- )
- )
- goto :eof
复制代码
|