Recursively Rename File Extensions Across Multiple Drives

1

I have this for a batch file. I know squat about batch files.

FOR /r %%x IN (*.BMP,*.GIF,*.JPG,*.PNG) DO REN "%%x" *.jpeg

Which works fine locally. I need this to work across multiple drives (c:,d:,e:,f:,g:,h:,i:,j:).

Any help would be greatly appreciated. Thank you for your time and effort.

Cheers!

Modussn

Posted 2014-03-29T13:21:26.010

Reputation: 11

Why do you want to change the file extension of different image types to .jpeg? Why do you even want to change .jpg files to .jpeg? .jpeg is an erroneous extension that shouldn't even exist. – paradroid – 2014-03-29T16:55:12.660

Answers

1

Here's a batch script that does what you want:

@echo off
setlocal

set drives=c,d,e,f,g,h,i,j
set exts=*.bmp;*.gif;*.jpg;*.png

for %%A in (%drives%) do (
cd /d %%A: && for /r %%B in (%exts%) do ren "%%~B" "%%~nB.jpeg"
)

pause >nul
endlocal & exit /b

Further reading

and31415

Posted 2014-03-29T13:21:26.010

Reputation: 13 382