How can I remove Finder tags from all files in a given folder and in its subfolders?

  • I wish I had an answer, I'm curious as well. If you're handy with the shell then the mdfind command may be part of your solution in the end. Good luck. – Charlie Wilson May 12 '14 at 20:16

You can use Homebrew's tag:

brew install tag
tag -r /path/*

You can combine this with a find command to find specific files/folders + recursive.

find . -exec tag -r {} \;  -print
  • How does one go about using the last line of code on a directory? I don't want to screw up and remove tags from every folder in my system: find . -exec tag -r /path/ {} \; -print. Furthermore, can I just cd to a directory and perform that command? – Matt Swift Apr 15 '17 at 15:06
  • @Matt The find command has two components: the path/filter and the action. find . will use the current directory that you've cd'd to, or you can use find /path/to/folder and specify the path there. No filter is given so every file and folder beneath the given path will match. -exec …; will execute the command, replacing {} with each matched path. -print also prints the matching paths. You can ‘dry run’ the command by removing the ‘exec’ and just using find . -print (which is equivalent to find .), which will print the list of files matched without doing anything else to them. – grg Apr 15 '17 at 15:18

You can also use xattr:

xattr -dr com.apple.metadata:_kMDItemUserTags ~/folder
xattr -dr com.apple.FinderInfo ~/folder

If you don't delete the com.apple.FinderInfo extended attributes, Finder keeps showing the color labels for tags with colors. If you don't want to keep any extended attributes, you can just run xattr -cr ~/folder.

You can use find -xattrname or mdfind to find files with tags:

find ~/folder -xattrname com.apple.metadata:_kMDItemUserTags
mdfind -onlyin ~/folder kMDItemUserTags=\*

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .