So,  you’ve wound up with a huge number of files, folders and sub-folders with a extended attribute?  (I’ll assume you already know that Mac OS X puts this on downloaded files for security reasons.  This is the thing that triggers the OS to ask you if you’re sure you want to open something that came from the internet.)  See my other recent entry on why this may have happened if you don’t know.

To remove these will take some scripting. The only thing that removes them that is provided in the OS is the command-line tool “xattr”.   Unfortunately, you can’t just specify a folder to cleanse recursively.

I did experiment with xattr and some scripts for it that I found on the internet.  But they ran terribly slowly.  Depending on the situation, they may produce a lot of “no such attribute” errors which made things even slower. After watching one such script grind on for a while,  I ran

ls -laR | grep “@” | wc -l

and it promptly showed 600+ items with extended attributes still remaining.

I finally hit upon this shell script which did the whole thing in a blink for everything in the current working directory:

for f in find ./ -type d
cd “$f”
xattr -d *

Calling xattr with “*” cleans out an entire directory very quickly.  It may still generate errors if some of the files/folders do not have a matching extended attribute.  The results of “find ./ -type d” are only the directories in the tree, so we call xattr once for each directory instead of once for each file.

I was hoping to make this into an easier-to-use script for use in a drag-and-drop applescript application, but I ran out of time.