another MS question

rbraxton

Board Regular
Joined
Oct 17, 2002
Messages
197
Does anyone know how to change the dot-three (i.e., .jpg) extension on A LOT of files at once?

Is there a free program that will do it?

:help:
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
The way I know is using a little vb script code.

If you change the variables in SETTINGS section then it can work for you.

Code:
Dim fso
Dim fld
Dim blnSubs
Dim strPath
Dim strExtOld
Dim strExtNew
      
  '*****SETTINGS*****
  blnSubs = True        'Set True to change files in subfolders as well, 
			'Set False to work in only root of the given path
  strPath = "C:\Temp"   'Path to work in
  strExtOld = ".jpg"    'Old extension
  strExtNew = ".jpeg"    'New extension
  '******************
  
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set fld = fso.getfolder(strPath)
  
  Call ChangeExt(blnSubs, strPath, strExtOld, strExtNew, fld)
  
  Set fso = Nothing
  Msgbox "Done!"

Sub ChangeExt(blnSubs, strPath, strExtOld, strExtNew, fld)
Dim subfld
Dim fil
  If blnSubs Then
    For Each subfld In fld.subfolders
      Call ChangeExt(blnSubs, strPath, strExtOld, strExtNew, subfld)
    Next
  End If
  For Each fil In fld.Files
    If Right(fil.Name, len(strExtOld)) = strExtOld Then
      fil.Name = Left(fil.Name, Len(fil.Name) - len(strExtOld)) & strExtNew
    End If
  Next
End Sub

Open Notepad, New file, Copy and Paste the code above and change SETTINGS (path, old ext, new ext, choice for subfolders) then save it as "freeapp.vbs" on desktop then double click on this VBScript file to execute it.

Or you can just use my code as a sample to produce your own free program:). Either way, you take your own risk to change your file extensions with a code automaticially. I would do that really carefully.

I hope I understood your question correct and it helps.

Suat
 
Upvote 0

Forum statistics

Threads
1,223,277
Messages
6,171,148
Members
452,382
Latest member
RonChand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top