Page 1 of 1

Use contents of text file to create tags

PostPosted: Fri Dec 20, 2019 4:06 pm
by heshca
I’m looking to automate an aspect of my note-taking workflow. I currently keep all my notes in individual markdown (.md) files in a single folder. In every file there is a line that will read something like this

Tags: #tag1 #tag2 #tag3

What would be incredibly helpful would be a Hazel rule that takes each hashtag and turns it into a Mavericks tag (Do we still call them this?) for the file.

Thanks

Re: Use contents of text file to create tags

PostPosted: Mon Dec 23, 2019 12:59 pm
by Mr_Noodle
Will there always be 3 tags? If not, then it may be a bit tricky and require a script.

Also, just "tags" is fine.

Re: Use contents of text file to create tags

PostPosted: Tue Dec 24, 2019 11:25 am
by heshca
Mr_Noodle wrote:Will there always be 3 tags? If not, then it may be a bit tricky and require a script.

Also, just "tags" is fine.


No, there will be a variable number of tags, but each will always be accompanied by a # to denote a new tag. It seems like the steps required for a script might be something like:

1. Date modified after date last matched
2. Identify individual tags in markdown text (use grep?) and store in variables
3. Compare those tags to the current tags, if they exist
4. Remove tags no longer present
5. Add new tags

I have no programming abilities, but I could take a crack at it.