.bat for batch rename to increment numbers in fname

前端 未结 2 681
心在旅途
心在旅途 2021-01-06 16:33

I have a large folder of .cbr\'s, and I\'m renaming them by issue number to correctly order them. What do I need to include in the ren line to have each file increment the n

2条回答
  •  时光取名叫无心
    2021-01-06 17:25

    Try this batch script.

    @echo off
    setlocal enabledelayedexpansion
    set /a count=0
    for /f "tokens=*" %%a in ('dir /b /od *.cbr') do (
     echo ren "%%a" !count!.cbr
     set /a count+=1
    )
    

    It renames all the files with a incremental counter. The order of the files is preserved with the /OD option of the DIR command, that sorts the files list by its modified timestamp.

    After careful testing, remove the ECHO command.

    For more information, read HELP DIR, HELP SET and HELP FOR.

提交回复
热议问题