Quick Tip: Batch SVN Rename of files through Powershell

Published Jul 29, 2013 (11 years ago)
Danger icon
The last modifications of this post were around 11 years ago, some information may be outdated!

Quick TipI'm trying to use Powershell more and more, and today I ran into a directory in one of my projects that had a lot of files that needed renaming. Here's the trick on how to do it in Powershell.

I needed all filenames that had a space in them replaced with an underscore so that they would run properly in our batch scripts. In addition, I needed to do this through SVN, and not just a standard rename, so that our other developers noted the changes as well.

After a little tweaking, here's the quick and easy way to do it through Powershell.

[gist]6106435

Note that I've formatted this on multiple lines for readability, simply remove the newline characters so that it is a single line and you can run it at the command prompt in the directory of your choosing.

If you need to tweak things a little, make sure to change the -match parameter on the first line to the character (and potentially string) that you're filtering off of, as well as the replace statement.

Enjoy!