Remove all .svn folders, recursively

Whenever I’ve left a website to a client for an extended period of time I feel the need to update the files in my repository to make sure it’s up to date. Before you replace the files in trunk with the files from the server it’s essential that you get rid of those pesky .svn system folders that will have been pushed to the production server when the site was deployed.

First things first, make sure you have your system files shown so that you can verify that the .svn folders have been removed.

For Mac OS X (via terminal)

defaults write com.apple.finder AppleShowAllFiles TRUE

killall Finder

For PC (thanks to Lawrence Abrams):

  1. Close all programs so that you are at your desktop.
  2. Click on the Start button. This is the small round button with the Windows flag in the lower left corner.
  3. Click on the Control Panel menu option.
  4. When the control panel opens click on the Appearance and Personalization link.
  5. Under the Folder Options category, click on Show Hidden Files or Folders.
  6. Under the Hidden files and folders section select the radio button labeled Show hidden files, folders, or drives.
  7. Remove the checkmark from the checkbox labeled Hide extensions for known file types.
  8. Remove the checkmark from the checkbox labeled Hide protected operating system files (Recommended).
  9. Press the Apply button and then the OK button..
  10. Now Windows 7 is configured to show all hidden files.

Finally, navigate to the folder where the site files are stored and run this command:
For Mac OS X

rm -rf `find . -type d -name .svn`

For Windows (thanks to Adam Anderson):

for /r %R in (.svn) do if exist %R (rd /s /q "%R")