Page 1 of 1

Any way to retrieve all file tags from Hazel?

PostPosted: Tue Jun 04, 2024 1:39 pm
by andy4222
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

Re: Any way to retrieve all file tags from Hazel?

PostPosted: Wed Jun 05, 2024 8:35 am
by Mr_Noodle
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.

Re: Any way to retrieve all file tags from Hazel?

PostPosted: Wed Jun 05, 2024 2:38 pm
by andy4222
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?

Re: Any way to retrieve all file tags from Hazel?

PostPosted: Fri Jun 07, 2024 8:30 am
by Mr_Noodle
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.

Re: Any way to retrieve all file tags from Hazel?

PostPosted: Fri Jun 07, 2024 1:36 pm
by andy4222
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

Re: Any way to retrieve all file tags from Hazel?

PostPosted: Mon Jun 10, 2024 9:02 am
by Mr_Noodle
Does Terminal have Full Disk Access?

Re: Any way to retrieve all file tags from Hazel?

PostPosted: Sat Jun 15, 2024 12:49 pm
by andy4222
Mr_Noodle wrote:Does Terminal have Full Disk Access?


Yes it does

https://ibb.co/qkZVCPw

Re: Any way to retrieve all file tags from Hazel?

PostPosted: Mon Jun 17, 2024 8:41 am
by Mr_Noodle
Check for ~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ProjectsItems (the extension may vary depending on your OS version and history).

Re: Any way to retrieve all file tags from Hazel?

PostPosted: Wed Mar 12, 2025 2:47 am
by andy4222
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?

Re: Any way to retrieve all file tags from Hazel?

PostPosted: Wed Mar 12, 2025 8:20 am
by Mr_Noodle
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.

Re: Any way to retrieve all file tags from Hazel?

PostPosted: Mon Mar 24, 2025 11:26 pm
by andy4222
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

Re: Any way to retrieve all file tags from Hazel?

PostPosted: Tue Mar 25, 2025 8:57 am
by Mr_Noodle
plutil. You can use it to convert it to a text version.