Folder Action: Strip Subversion .svn metadata
I regularly need to send a zipped copy of a folder that is a local Subversion working copy. Every time I create the archive I end up with a file that’s larger than needed, because it contains the hidden Subversion metadata “.svn” subfolders.
Here is quickly hacked together AppleScript than delegates the actual work to the Unix “find” command, but can be attached as a Folder Action. I now have folder on my Desktop called “Strip SVN Metadata” and I just Option-Drag anything from a Subversion working copy there (making a copy, not moving) and a few seconds later I can just zip it from there without the .svn folders.
on adding folder items to this_folder after receiving added_items tell application "Finder" set fold_name to the name of this_folder try repeat with i from 1 to number of items in added_items set new_item to item i of added_items set the item_path to the quoted form of the POSIX path of new_item do shell script ("/usr/bin/find " & item_path & " -name '.svn' -type d -exec rm -rf {}") end repeat end try end tell end adding folder items to
Comments