25 thoughts on “command line script to delete .svn files / folders”

  1. Doesn’t work.

    C:\>find ./ -name “.svn” | xargs rm -Rf
    ‘xargs’ is not recognized as an internal or external command,
    operable program or batch file.

    C:\> 😛

  2. Great hint. Also, for those that don’t know, you can checkout a clean copy of the code directly from subversion by using “svn export”. This leave you with a perfect copy of the code, without the .svn folders.

  3. Here is a slightly more efficient way of doing the same thing:

    find ./ -name .svn -exec rm -rf {} \;

    When you use -exec find will execute the command for every result returned via the find query into the argument {}

    Another useful command is to only perform and operation on files that have not been added or modified. You can do this like so:

    svn status | grep ? | awk ‘{print $2}’ | xargs rm -rf

    This would remove any file that has been added to the repository.

    Breaking it down

    svn status will return results like this:

    ? foo
    M build/projects/Community.iml
    M build/build.properties

    Piping it through grep ? will give you:

    ? foo

    Awk can be used to print out the column we want that is what the print $2 part of the awk command is for.


    finally pass the results to xargs rm

    Hope this is interesting.


  4. I found another choice. Just to share it with all of you:

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

    The key is the grave accent quotes in this case. It worked in a split second.

  5. If the paths contain spaces then this will do:

    find ./ -name ".svn" -print0 | xargs -0 rm

    but again as many people already posted the pipeless version is nicer:

    find ./ -name .svn -exec rm -rf {} \;

Leave a Reply

Your email address will not be published. Required fields are marked *