批量重命名 - Android Bootanimation - 重命名文件,它们之间的步长介于1到100之间

时间:2014-09-13 10:24:34

标签: android batch-file file-io batch-rename boot-animation

我有100个连续的PNG文件,用于一个启动动画。但是他们之间有不同的步骤

  

示例: 1,4,5,10,14,15,16,19 ......

使用Ant Renamer就足够了,而且它是一个很好的应用程序,但我喜欢使用带有批处理文件的旧黑屏。

任何人都可以给我一个想法,如何将它们从1重命名为100,保留序列的顺序?

1 个答案:

答案 0 :(得分:1)

保存为批处理文件,并以文件夹路径作为参数调用。默认情况下,处理当前文件夹

@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