用批处理重命名文本文件名的代码
程序员文章站
2022-03-07 21:01:21
实现代码1@echo off&setlocal enabledelayedexpansion for /f "delims="&nb...
实现代码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
上一篇: C#中List用法介绍详解
下一篇: 批处理隐藏自身窗口,很无聊