HappyXxxxxx 当前离线
列兵
@echo off cd /d G:\ZL\DownLoad\JD_Pics_Collection echo %cd% for %%i in (*.*) do (ren %%i head%%i) rem 为了调试方便,本次运行前,先把上次的运行结果前面加个“head”前缀 ren headfile_type_list.txt file_type_list.txt setlocal enabledelayedexpansion for /f %%i in (file_type_list.txt) do ( echo %%i set /a count=0 set file_type=%%i for %%j in (*.!file_type!) do ( echo %%j set /a count+=1 set cond1=ren "%%j" !file_type!-00!count!.!file_type! & echo "%%j" --^> !file_type!-00!count!.!file_type! set cond2=ren "%%j" !file_type!-0!count!.!file_type! & echo "%%j" --^> !file_type!-0!count!.!file_type! set cond3=ren "%%j" !file_type!-!count!.!file_type! & echo "%%j" --^> !file_type!-!count!.!file_type! if !count! LSS 10 (!cond1!) else (if !count! LSS 100 (!cond2!) else (!cond3!)) ) ) PAUSE复制代码
qixiaobin0715 当前离线
大校
评分人数
TOP
把所有无参数的循环中存在ren命令的,全部改为for /f形式看看。 qixiaobin0715 发表于 2023-5-19 10:04
for /f "delims=" %%j in ('dir /a-d-h /b *.!file_type!')复制代码
@echo off for %%i in (gif jpg webp) do ( setlocal enabledelayedexpansion for /f "delims=" %%j in ('dir /b /a-d "*.%%i"') do ( set /a n+=1 set m=00!n! set m=!m:~-3! ren "%%j" "%%i-!m!.%%i" ) endlocal ) pause复制代码
@echo off setlocal enabledelayedexpansion set n=1 echo,!n! setlocal enabledelayedexpansion set n=8 echo,!n! endlocal echo,!n! pause复制代码