Skip to main content

Bulk rename Subversion files with PowerShell

Tags:
Reading time: 1 minute Suggest a change

Scenario: We're upgrading our reporting software at work, and the way that it used to integrate with SVN (through a terrible SCC bridge) involved arbitrarily placing "app*" at the head of the file names. Of course, in the new version, they no longer do this, and so all of our SVN references are out of whack. While renaming all of them to remove the "app*" at the beginning isn't the entire solution, it's one step I had to follow that I believe will be of benefit to others.

I used the following PowerShell script to pull it off:

	Get-ChildItem -recurse |
		Where-Object {
			-not $_.PsIsContainer -and $_.Name -match "^app_"
		} |
		ForEach {
			$fullname = $_.FullName
			$newname = $fullname -replace '\\app_', '\' iex "svn rename '$fullname' '$newname'"
		}

Note: You will need a command-line SVN client to do this. I used CollabNet's SVN client, but there are others out there.