Dan on eScience & Technical Computing @ Microsoft

eScience & Technical Computing - Web Services and Scientific Research

Rename file extension with PowerShell

Rename file extension with PowerShell

  • Comments 1

Last week I ended up finding that one of my directories of pictures lost their file extensions – so I thought I’d spin up PowerShell in Win8 and see if I could remember how to do. Smile 

After a little trial and error I ended up with the following PowerShell Script – reminded me how powerful and easy PowerShell is for scripting all of Windows.

  1. $proj_files = Get-ChildItem | Where-Object {$_.Extension -ne ".jpg"}
  2. ForEach ($file in $proj_files) {
  3. $filenew = $file.Name + ".jpg"
  4. Rename-Item $file $filenew
  5. }
Leave a Comment
  • Please add 7 and 5 and type the answer here:
  • Post
  • From cmd.exe, "ren *. *.jpg" will add .jpg to files that don't have an extension.  "ren * *.jpg" will replace existing extensions too.

Page 1 of 1 (1 items)