Jump to content

Get all tags available


Recommended Posts

Posted

Is there a way to find all the available tags in the file system? If not, would be good to surface them via automation tasks. Right now, if we add a new tag, we have to add the tag in the finder and also in Alfred.

Posted

Not an automation task and I'm not sure how you would use it in the, I assume, Label Color Tag workflow, but you could get the tags like this:

 

mdfind -onlyin ~/Documents "kMDItemUserTags=*" | xargs -I{} mdls -name kMDItemUserTags {} | sed -e 's/kMDItemUserTags = (//; s/)//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d' | tr -d ',"' | sort | uniq

 

 

Depending on how many tagged files you have on your system, this may take a while. To search the entire filesystem, you can replace ~/Documents with just ~, which could take quite a long while.

 

To have a continuous stream of (unfiltered) tags, you can try this in the terminal to make sure that it works:

mdfind -onlyin ~ "kMDItemUserTags=*" | xargs -I{} mdls -name kMDItemUserTags {} | sed -e 's/kMDItemUserTags = (//; s/)//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d' -e 's/\"//g' -e 's/\,//'

 

Press ctrl+C to stop the process.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...