- @echo off
- SETLOCAL ENABLEDELAYEDEXPANSION
- ::本批处理功能为将当前文件夹下所有以阿拉伯数字命名的文本文件“按序”排列
- ::注意事项:当前文件夹中的文本文件名必须为阿拉伯数字,数字之间不允许空格
- ::当然可以根据自己的需求继续完善
- set max=1
- for %%a in (*.txt) do (
- set %%~na=%%~na
- if !max! lss %%~na set max=%%~na
- set /a cnt+=1
- )
-
- for /l %%a in (1,1,%cnt%) do (
- if defined %%a (
- set %%a=
- ) else (
- set _tmp=%%a
- call :reName %%a
- )
- )
- echo done......
- pause>nul
- exit
-
- :reName
- for /l %%a in (1,1,%max%) do (
- set /a _tmp+=1
- if defined !_tmp! (
- echo ren !_tmp!.txt %1.txt
- set !_tmp!=
- pause>nul
- goto :eof
- )
- )
复制代码
|