Automator Workflow to Delete All Hidden .svn Folders For OS X 10.5
Updated on 9/28/2009 at 11:58AM EST
Anyone who has ever used Subversion knows that it can be a chore to clean up a folder that you wish to remove from source control. For example, you want to transfer a web site over to the web server, but don't want all the hidden .svn folders to be copied as well. On the Macintosh, it's even more of a pain because Apple's attempt to make the computer easier to use, has rendered it near impossible to manage hidden files.
I searched the web for an answer, and found several Automator workflows that claimed to delete all the hidden .svn folders from a given path, but none worked in OS X 10.5. Something changed. All the "rm" operations to delete files and folders returned "Operation denied" type error messages. It turns out that it was the fact that the files are locked, and the "rm" command cannot delete locked files. Simple enough. So I wrote the Automator workflow below, which can be installed as a Finder plugin, allowing you to right-click a folder and execute the workflow in one step. Perfect! Now, it's easy to find and remove all those hidden .svn folders.
Download the workflow, and open it with Automator. Then save the workflow as a "Plug-In", and it will install it into the Finder's contextual menu, under "More -> Automator".
Remove .SVN Folders.workflow.zip (63.11 kb)
You can also follow the steps below to manually create the workflow.
- Create a workflow.
- Add the finder item "Get Selected Items"
- Add a "Run Shell Script" item.
- In the Shell Script item, choose to pass input "as arguments", choose a Shell of "/bin/bash", and use the script below as the command text:
for f in "$@"
do
find "$f" -name .svn -print0 | xargs -0 chflags -R nouchg
find "$f" -name .svn -print0 | xargs -0 rm -fr
done
You could get fancy, and add "Ask for Confirmation" to the very top of the workflow, so be prompted before executing the command. Either way, it works great. Your last step would be to "Save" the workflow as a Finder plugin, by choosing "File > Save as Plug-In". Now, log off and then back on, and right click a folder. From the contextual menu, simply choose "More" and you should see Automator actions as a menu option. Your plugin is in there.
I hope I've saved you a few pain relievers.
9775ab6f-1206-4f32-a8b8-1361c95162d6|0|.0