Windows – How to rename multiple files with same name and different extensions

batch-renamepowershellrenamewindows 10

Screenshot

I have a number of files with the same name and different extensions in a folder. Originally these files were all in .jpg format with different names.

Like:
1.j87
1.j88
1.j89

Now I've to rename each image to different name and extension individually.

I found this, but I don't know how to use this script. Can someone help?

Best Answer

I know how to accomplish this with Windows CMD shell after you change to the directory of your JPG files.

Save this script to a BAT file such as renamer.bat or any non-reserved command and execute it from your command prompt.

setlocal enabledelayedexpansion

set /a count=0
for /f "tokens=*" %%a in ('dir /b /od *.jpg') do (

    ren %%a ArbitraryString!count!.jpg
    set /a count+=1

)

Based on your question, it sounds like you also want to rename every *.jpg file something different than *.jpg, which would cream your file associations and make the images tedious to open. If this is REALLY TRUE, then substitute the Rename line with:

ren %%a ArbitraryString!count!.!count!jpg
Related Question