我有 100 个连续的 PNG 文件,用于一个开机动画。但是它们之间的步骤不同
Example: 1, 4, 5, 10, 14, 15, 16, 19...
使用 Ant Renamer就足够了,它是一个很好的应用程序,但我喜欢用带有批处理文件的旧黑屏来完成。
谁能给我一个想法,如何将它们从 1 重命名为 100 并保留序列的顺序?
最佳答案
保存为批处理文件并以文件夹路径作为参数调用。默认处理当前文件夹
@echo off
setlocal enableextensions disabledelayedexpansion
rem - Set folder to be processed
set "folder=%~1"
if not defined folder set "folder=%cd%"
rem - Prepare work environment
pushd "%folder%" & setlocal enabledelayedexpansion
rem - Load file list into array with number padding
for /f %%a in ('dir /b /a-d "*.png"^|findstr /i /r /x /c:"[0-9]*\.png"') do (
set /a "n=100000000+%%~na"
set "n[!n!]=%%a"
)
rem - Retrieve the list from memory and, for each element in the
rem array, rename the file to the correct name
set "n=1"
for /f "tokens=2 delims==" %%a in ('set n[') do (
set "name=000!n!"
echo ren "%%a" "!name:~-3!.png"
set /a "n+=1"
)
rem - Cleanup
endlocal & popd
endlocal
关于android - 批量重命名 - Android Bootanimation - 将文件重命名为 1 到 100 之间的不同步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25822249/