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
}

Related Posts:

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>