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
  • Twitter
  • Posterous

8 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.


  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.


  7. Bob Says:

    With the slightest of tweaks, this was actually useful to me. Sometimes svn crashes and leaves your working copy ‘locked’. Changing the cmd-line to:

    find -type f -name “lock” -exec rm ‘{}’ \; -print

    …enabled me to quickly get rid of all those pesky lock files.

    Just make sure there’s no real content called “lock” ;)


  8. Mahbub Says:

    How about

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

    It works for me :)

Leave a Reply

Fork me on GitHub