Wednesday, October 2, 2013

Rename multiple files in a folder incrementally using this batch file

Rename multiple files in a folder incrementally using this batch file


::Setup the stage...
SETLOCAL ENABLEDELAYEDEXPANSION
SET folder=D:\ABC
SET count=1
::Action
CD "%folder%"
FOR %%F IN ("*.jpg") DO (
 MOVE "%%F" "!count!.jpg"
 SET /a count=!count!+1
)
ENDLOCAL

Note: Put this batch file in that folder where other files that needs to be renamed are available and then run the same.