DOS batch script to rename multiple files with formatted date.
Create a “rename.bat” file using any editor and copy paste the given code. You may change to file extension as per your need.
Save and run the file. Processes file in the current folder only.
Rename | Formatted date | “-” separator
E.g. “20181125.jpg” to “2018-11-25.jpg”
ECHO OFF
for %%i in (“.jpg” “.jpeg” “.png” “.mp4″) do (set fname=%%i) & call :rename
goto :eof
:rename
SET y=%fname:~0,4%
SET m=%fname:~4,2%
SET d=%fname:~6,2%
SET endfname=%fname:~8%
SET nfname=%y%-%m%-%d%%endfname%
ECHO %fname% TO %nfname%
REN “%fname%” “%nfname%”
goto :eof
Rename | Whatapp files
E.g. “WhatsApp Image 2021-03-14 at 5.57.08 AM.jpeg” to “2021-03-14 at 5.57.08 AM.jpeg”
ECHO OFF
for %%i in (“.jpg” “.jpeg” “.png” “.mp4″) do (set fname=%%i) & call :rename
goto :eof
:rename
SET endfname=%fname:~15%
SET nfname=%endfname%
ECHO %fname% TO %nfname%
REN “%fname%” “%nfname%”
goto :eof
Rename | Mobile Snap files | Formatted date | “-” separator
E.g. “IMG_20210313_074330.jpg” to “2021-03-13_074330.jpg”
ECHO OFF
for %%i in (“.jpg” “.jpeg” “.png” “.mp4″) do (set fname=%%i) & call :rename
goto :eof
:rename
SET y=%fname:~4,4%
SET m=%fname:~8,2%
SET d=%fname:~10,2%
SET endfname=%fname:~12%
SET nfname=%y%-%m%-%d%%endfname%
ECHO %fname% TO %nfname%
REN “%fname%” “%nfname%”
goto :eof