@echo on setlocal enabledelayedexpansion set n=0 set n1=0 for /f "tokens=*" %%a in (a.txt) do ( set /a n+=1 ren %%a t!n!.jpg ) :loop set /a n1+=1 ren t%n1%.jpg %n1%.jpggoto :loop exit
第二種方法 好像可以更簡單點
復(fù)制代碼 代碼如下:
@echo off ren *.jpg t*.jpg setlocal enabledelayedexpansion for /f "delims=" %%a in ('dir/b "t*.jpg"') do ( set str=%%aset str=!str:~1! ren "%%a" "!str!" ) pause