Batch name files in the form of increasing serial numbers

Original link: https://www.sey.ink/5691/

Create a .txt file and enter the following content and save it as .bat format

 @echo off setlocal enabledelayedexpansion set count=900 for /f %%i in ('dir /b *.jpg,*.png,*.bmp,*.jpeg,*.gif') do (     set /a count+=1     echo renamed: %%i !count!     rename %%i !count!.jpg ) 

Here the numbering starts from 901. To start the numbering from x (for example, 100), set count=99(x-1)

To set the named number of digits, such as 99 above, but not 099, etc., the following statement needs to be used. If we want to start sorting from 0901, we can use the third line of code: set count=10900

 @echo off setlocal enabledelayedexpansion set count=10900 for /f "delims=" %%i in ('dir /b *.jpg,*.png,*.bmp,*.jpeg,*.gif') do call:Rename "%%~i" pause exit   :Rename set /a count+=1 if /i "%~1"=="!count:~1!%~x1" goto :eof if exist "!count:~1!%~x1" goto Rename echo renamed: %1 !count:~1! ren "%~1" "!count:~1!%~x1" goto :eof 

The above method plus one step can realize a webpage that randomly displays a picture?

Reminder : Hidden content can only be viewed after reply/comment , please refresh after commenting! .

The first post on Bulk Name Files with Incrementing Serial Number appeared on Xian Sen’s blog .

This article is reprinted from: https://www.sey.ink/5691/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment