本帖最后由 flashercs 于 2022-5-16 16:13 编辑
- @echo off
- setlocal enabledelayedexpansion
- cd /d "%~dp0"
- for /d %%A in (*) do (
- set ctr=0
- set t=%%~A
- set "t=!t:,=,!"
- set "t=!t:、=,!"
- set "t=!t:-=,!"
- for %%B in (!t!) do (
- set /a ctr+=1
- call :getNewName "%%~B"
- if !ctr! equ 1 (
- set firstdir=%%~B
- ) else (
- 2>nul md !newname!
- xcopy "%%A\*" !newname! /e
- )
- )
- if !ctr! gtr 1 (
- call :getNewName "!firstdir!"
- ren "%%A" "!newname!"
- )
- )
- endlocal
- pause
- exit /b
- :getNewName oldname
- set n=0
- set newname="%~1"
- :loop
- if not exist %newname% (
- exit /b
- )
- set /a n+=1
- set newname="%~1_%n%"
- goto loop
- exit /b
复制代码
|