Any way to retrieve all file tags from Hazel?

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

I started using tags and see Hazel auto updates these tags in it's user interface whenever I add a new tag in Finder. Any programmatic way to retrieve these tags from Hazel (or Finder?). I want to retrieve these tags so I can use Alfred to assign tags and Hazel can do it's magic in the background. Alfred itself doesn't have a way to do this but hoping I can fetch them from Hazel since it already has them somewhere in it's DB
andy4222
 
Posts: 18
Joined: Sun Dec 27, 2020 3:19 pm

Unfortunately, Apple doesn't provide an API for this so I had to reverse-engineer it. There's a plist file that I parse and I supplement that with a Spotlight search.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:Unfortunately, Apple doesn't provide an API for this so I had to reverse-engineer it. There's a plist file that I parse and I supplement that with a Spotlight search.


Thanks. Could you please share which file is this and your approach on how you do it?
andy4222
 
Posts: 18
Joined: Sun Dec 27, 2020 3:19 pm

It's a bit detailed but just add a tag with text that doesn't appear anywhere else on your system. Doing a recursive grep of ~/Library should pick up which file it is on your system.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:It's a bit detailed but just add a tag with text that doesn't appear anywhere else on your system. Doing a recursive grep of ~/Library should pick up which file it is on your system.


Don't see anything for some reason https://ibb.co/1Zd2jTC

https://ibb.co/jwVpcYN
andy4222
 
Posts: 18
Joined: Sun Dec 27, 2020 3:19 pm

Does Terminal have Full Disk Access?
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:Does Terminal have Full Disk Access?


Yes it does

https://ibb.co/qkZVCPw
andy4222
 
Posts: 18
Joined: Sun Dec 27, 2020 3:19 pm

Check for ~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ProjectsItems (the extension may vary depending on your OS version and history).
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Returning back to this thread. I tried searching for that file, but that file seems to be some sort of binary file.

~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ProjectsItems

Any other approach you can suggest to fetch all the tags?
andy4222
 
Posts: 18
Joined: Sun Dec 27, 2020 3:19 pm

It's a binary plist file. If you have the developer tools installed, there is a commandline tool to read those in. As mentioned, Apple does not expose this to developers, let alone users so there really is no other way that I know of.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:It's a binary plist file. If you have the developer tools installed, there is a commandline tool to read those in. As mentioned, Apple does not expose this to developers, let alone users so there really is no other way that I know of.


I do have developer tools installed. Which developer tool are you talking about? I tried opening it in sublime, but it opens up as a binary
andy4222
 
Posts: 18
Joined: Sun Dec 27, 2020 3:19 pm

plutil. You can use it to convert it to a text version.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support