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


Unknown said…
Have you tried to directly use the "Export" feature of svn?
Yes, certainly. However sometimes this is just easier. You can also combine the script with the ZIP functionality to safe another step.
A Booth said…
Anonymous said…
A script is easier how? If you're using an IDE with a plugin like Subclipse or a proper modern tool like TortoiseSVN like a good productive developer should, you don't even bother with a command line. Right click->Export, click, done. What could be easier? If such tools aren't an option for some reason, you're doing something wrong.

Popular posts from this blog

SAXParseException: -1:-1: Premature End Of File - Misleading error

Amiga 500 Restoration: A501 Memory Expansion

Something to know about Toshiba external USB HDD