Remove SVN files with automator
We’ve been using subversion pretty extensively recently and loving the idea of it (though it is rather finicky). When reusing files for multiple projects, often you’ll want to just copy and paste folders and files right into another project. This poses a problem when using subversion because if the folder already contains .svn files, you won’t be able to add it to another repository. So, you first must delete those files. This is the command line script we’ve been using to remove them (recursively from the directory you are currently in):
find . -name .svn -print0 | xargs -0 rm -rf
It’s a pain having to open terminal though, so here’s a nice way of accomplishing the same result using Automator:

You can find all of these actions under “Applications” in the Automator Library. Starting with (1) Ask for confirmation, we prompt the user to make sure they want to continue. (2) Gets a list of selected finder items [if you had a group of directories selected, it makes a list of those]. At (3), the script we were using before is run on each item (removing the “.svn” file in each directory):
for f in "$@" do find "$f" -name .svn -print0 | xargs -0 rm -rf echo "$f" done
Then at (4) it outputs the list of items cleared to a text file on the desktop. When compiling to a plug-in (explained further down) I have this “disabled” so I don’t get that textfile every time. Perhaps you could do something like output the results to the console.
You can then go to File > Save As Plugin… Save the file (I called it “ClearSVN”) as a Plug-in for: Finder. This enables you to right click a directory, go to Automator… and select “ClearSVN” which would clear the .svn files inside that directory!
NOTE that this is for OS Tiger. In Leopard, the actions seem to be slightly different, but could be updated to work the same way.



Thank you so much for this. I have been struggling with finding a way to delete the svn files and I was just about to give up and start manually going through each directory. :(
Thanks again!
Comment by Eric | 68KB — November 28, 2007 @ 8:58 am
[…] I recently installed SCPlugin for my Mac which allows a GUI interface to Subversion. One thing I haven’t been able to locate is the SVN export command. So every time I checkout I get all the hidden svn files. Luckily I found this great tutorial from Team BKWLD that uses Automator to recursively delete all the SVN files for a folder. […]
Pingback by Remove Pesky SVN Files | 68KB — November 28, 2007 @ 9:10 am
Great use of automator!
Comment by Annie — January 12, 2008 @ 10:46 am
[…] # Set new value for property ’svn:externals’ on ‘Flash/Classes/com’ svn st # X Flash/Classes/com/bkwld Now, you can see it’s an external link with the ‘X’ status. Now just run svn up to populate the ‘bkwld’ folder! Any updates to our Actionscript codebase can now be reflected in any number of other projects utilizing it (without copying and pasting changes). Brilliant. svn export Before export, if we needed files from another project we would often copy files from the working copy clear the .svn files (though that was a pretty sweet trick if I say so myself ;)) and then add them to the repository. I know a lot of people do this. Whether it’s using an automated script or just running it in Terminal, it’s a dangerous trick (I personally have accidently ran it on my ‘Websites’ folder — and it’s recursive — ouch). A better way to grab versioned files into a new working copy is to use svn export. This “exports a clean directory tree from the repository” (svn help export) meaning that the resulting directory structure will have no .svn folders to begin with. You can navigate to your working copy and run export and then svn add those new files to your working copy. For example […]
Pingback by TypeOneError Studios™ svn:externals and svn export — August 8, 2008 @ 1:12 pm
[…] It’s a tutorial on how to create the Automator action. Check it out here. Share and Enjoy: […]
Pingback by Top 5 Automator Actions for Simplifying Daily Work | Primal Skill Blog — September 11, 2008 @ 5:13 am
All you need to do is drag the folder with the right mouse button and it will copy it without the .svn directories!
Comment by Paul Feakins — September 30, 2008 @ 5:57 am