本帖最后由 batman 于 2012-12-29 01:06 编辑
- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('dir /b *.txt') do (
- set /p str=<"%%a"
- if not defined !str! (
- ren "%%a" "!str!.txt"
- set "!str!=a"
- ) else (
- set /a n=0&call :lp "%%a"
- )
- )
- exit
- :lp
- set /a n+=1
- if not exist "%str% %n%.txt" (
- ren %1 "%str% %n%.txt"
- ) else (
- goto lp
- )
-
复制代码
|