Ramblings of a Coder's Mind

Engineering × AI × Scale

K

Mass renaming file extensions with PowerShell

Note: This post was written in 2014 and discusses technology that may be outdated. The concepts may still be relevant, but specific tools/versions have changed.

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' }

Comments