Ramblings of a Coder's Mind

Got Tech? Will Hack.

Mass renaming file extensions with PowerShell

PowerShell is one of Windows’ most underused tools in my opinion. In many cases it rivals if not betters support that bash scripts provide.

If you want to remove the extension of a file (say removing ‘!ut’ from file names), it’s a simple one line command.

dir *.!ut | rename-item -newname { $_.BaseName }

If you want to add an extension, that’s pretty straight forward too

dir * | rename-item -newname { $_.Name + '.txt' }

Combine the two and you can change extensions too..

dir *.jar | rename-item -newname { $_.BaseName + '.zip' }
Created: Sun, 30 Nov 2014 16:08:17 +0530
Category: Tutorials
Tags: PowerShell, Scripts

Comments