Recursively remove .svn files

December 16th, 2005

Here’s a quick shell script to recursively remove all the the .svn files starting in the current directory and working down.

find . -type f -name "*.svn" -exec rm '{}' \; -print

Change .svn to look for different types.

  • del.icio.us
  • Digg
  • StumbleUpon
  • Technorati

6 Responses to “Recursively remove .svn files”

  1. Mike Says:

    This creates a “Run Shell Script” that never goes away in my title bar…

    Are you sure this is doesn’t end up looping?

  2. Hardwarerocks Says:

    The code above will not work.. Error..
    warning: the -d option is deprecated; please use -depth instead, because the latter is a POSIX-compliant feature.

    This one works..
    find . -type f -name “*.svn” -exec rm ‘{}’ \; -print

  3. Simon Says:

    Mike - not sure how you’ve run the script but it’s always been fine for me. Have you any other details.

    Hardwarerocks - Thanks for the info, the man page for find on my install (OS X Tiger) doesn’t mention that -d is deprectated. However I’ve changed the post accordingly.

  4. David Says:

    The .svn ‘files’ in question are folders which contain the subversion meta-data, including the pristine copies of the checked-out files of your working tree; deleting them means the tree can’t be used as a subversion working tree.

    I’m puzzled that you would want to treat an svn working tree this way, unless you specifically want a checked-out copy of the repository without the .svn folders. That’s what ’svn export’ is for.

  5. Akshay Surve Says:

    The semicolon afer .svn is missing.

    - Akshay

  6. Simon Says:

    @ David

    I understand where you’re coming from and if you use subversion correctly there should never be a need to remove the hidden svn files. However, from time to time, I do find that it’s necessary - generally when someone has mistakenly duplicated directories using the Finder in OSX.

Leave a Reply