用批处理重命名文本文件名的代码
(编辑:jimmy 日期: 2024/11/1 浏览:3 次 )
实现代码1
@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%a in ('dir/b *.txt') do (
set /a n+=1
if not exist "!n!.txt" (ren "%%a" "!n!.txt") else call :loop "%%a"
)
pause&exit
:loop
set /a n+=1
if exist "!n!.txt" goto loop
ren "%~1" "!n!.txt"
goto :eof
@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%a in ('dir/b *.txt') do (
set /a n+=1
if not exist "!n!.txt" (ren "%%a" "!n!.txt") else call :loop "%%a"
)
pause&exit
:loop
set /a n+=1
if exist "!n!.txt" goto loop
ren "%~1" "!n!.txt"
goto :eof
下一篇:批处理的api WMIC学习体会有感第1/2页