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

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


Solution 1:

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

Solution 2:

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=\*