Batch Remove Tags in OS X Terminal

I just wanted to delete all tags set in my Applications folder on OS X and had to look up how to accomplish that in the Terminal since it a) is quite cumbersome to do it in Finder and b) it did not quite work somehow.

The tags seem to be saved in the extended attributes com.apple.FinderInfo and com.apple.metadata:_kMDItemUserTags. For completeness, here is my complete “script”:

cd /Applications
for file in *; do 
  echo $file; 
  sudo xattr -d com.apple.metadata:_kMDItemUserTags "$file"; 
  sudo xattr -d com.apple.FinderInfo "$file"; 
done

That’s it and Cheers,

iss