Page 1 of 1

"keeping" tags - script execution stripping them

PostPosted: Wed Jan 14, 2015 3:50 am
by sandcastle
Hi.

I've created some really useful automation with Hazel, but I've just tried to tweak my workflow (the human element wasn't working!) and now I have a new challenge I can't seem to work around.

I have a rule that checks and does a few minor things to a file, then passes it to an OCR program by running a shell script. The problem is that this process seems to strip the tags from the file, even though it is only meant to process the file (not create a new one).

Is there any way read the current tags on a file, then call the shell script, then re-apply the same tags?

Thanks!

Re: "keeping" tags - script execution stripping them

PostPosted: Wed Jan 14, 2015 3:42 pm
by Mr_Noodle
It might be best to do that in the script itself. Also, if using a shell script, if you generate a new file, subsequent actions in the same rule will still apply to the original file, if it still exists. You'd need to use an AppleScript to tell Hazel the name of the new file that was generated if you want subsequent actions to apply to it.

Re: "keeping" tags - script execution stripping them

PostPosted: Wed Jan 14, 2015 6:42 pm
by sandcastle
Thanks.

That's beyond my current coding ability though! The other idea I had was if Hazel can read the tags, I could write them to the file name (that remains post shell script), then the second Hazel rule (that already exists) could maybe parse them from the filename and write them back as tags?

Either way, unless someone else has some example rules / scripts for me to work from, I'll have to put this back in the "one day when I have lots of free time" heap!

Thanks again though.

Re: "keeping" tags - script execution stripping them

PostPosted: Thu Jan 15, 2015 12:58 pm
by Mr_Noodle
You could try putting them in the filename. The Tags attribute is available via Spotlight. You'd probably want to have some characters to delineate which part of the filename is the tags list. Having Hazel set them back, though, is problematic since Hazel can't reinterpret that as a list of tags. At best, it would appear as one long tag.