,

Powershell: How to rename all files in a folder

1–2 minutes
3 comments on Powershell: How to rename all files in a folder

Powershell Header

Sometimes you need a fast way to rename a lot of file. With Powershell this is pretty easy. You list all files in the directory and you can use this object with a foreach loop.

This script basically changes the extension from .JPEG to .jpg:

$files = Get-Content
foreach ($file in $files) {
$newFileName=$file.name.replace(".JPEG",".jpg")
Rename-Item $file $newFileName
}

3 responses

  1. Rgeorge Avatar
    Rgeorge

    How to find and replace a name DBRMPK in an entire list of folders with DBRMPK , sub folders with name DBRMPK, file names with DBRMPK and file contents? DBRMPK to be replaced with RBRMPK.

  2. flaetearth-nanosincovaivaxx Avatar
    flaetearth-nanosincovaivaxx

    rename files not mean rename extensions…

    1. Thomas Maurer Avatar

      Correct, that is why you can just simply edit my example. :)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.