Use contents of text file to create tags

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

Moderator: Mr_Noodle

Use contents of text file to create tags 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
heshca
 
Posts: 4
Joined: Wed Dec 09, 2015 4:00 pm

Re: Use contents of text file to create tags 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.
Mr_Noodle
Site Admin
 
Posts: 11250
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Use contents of text file to create tags 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.
heshca
 
Posts: 4
Joined: Wed Dec 09, 2015 4:00 pm


Return to Support

cron