This is awesome Brett. The more I use it the more I love it!
I notice in the post that one of your primary contexts is Archive and was curious about how archiving works within this system. Do you replicate your directory structure under the Archive head context and move files across into the archive as they get old? (i.e. does a file tagged =Project :contract:pearson ultimately transition to =Archive :project:contract:pearson?
Initially I was thinking I wouldnt bother with archiving and just use file attributes (date created/modified) to sort or weed out older files in my search. However, thinking that I might face disk space issues on my air and archiving might be necessary. Probably has the side benefit of decluttering the shallow folder heirarchy with files that are years old.
It's working great only with Latin symbols. :) Is it possible to change script for Cyrillic? I'm not good in Ruby. Where do I look for fix it?
I always forget to check that. I'll add some encoding handling in and post it tomorrow.
It looks like most of the issues are actually coming from the way the `mdls` command returns UTF-8 characters from the shell (as escaped UTF codes), and nothing I do seems to allow me to unescape them. Thus it creates bizarre folder names and tags, and doesn't find matches where it needs to. I'll keep playing with it, but at this point I don't have a solution.
You inspired me to retroactively build out a tagging directory structure. So I had to write a script to accomplish that - https://gist.github.com/ano...
It walks through a directory structure, constructing tag names for the directories and tagging the files in the directories. It's intended to be used in a top-level context directory and will walk down from there, e.g., tagger.rb "#work".
Doesn't work for context directories that have spaces in them. Line 34:
targets= %x{for file in $(mdfind 'kMDItemUserTags == "=*"'); do mdls -raw -name kMDItemUserTags "$file"|grep '='|tr -d '."'|sed 's/^ *//'; done}.split("\n")
needs to be changed to this:
targets= %x{mdfind 'kMDItemUserTags == "=*"' -0 | xargs -L1 -0 mdls -raw -name kMDItemUserTags | grep "=" | tr -d '."' | sed 's/^ *//'}.split("\n")
Didn't even consider it because context tags with spaces require quoting in searches and that's a pain in the butt. But I'll update the gist, thanks for the code.
I can't get this to work by embedding a copy of the script in a Hazel action. It works fine if I run the command line you suggest. Does something in the script need to be changed to accomodate Hazel's directive to use $1to refer to the file being processed? If you are calling the script in Hazel some way other than embedding it, could you please post a screenshot of your Hazel rule. This is a great idea, and I'd obviously not want to have to do this file by file from the command line. Thanks much.
My mistake, you need to run it as an external script to work as is. I'll update the post to reflect that.
I run it as external, but I was thinking it would function the same embedded. You're right, it would probably have to be altered with the $1 somehow.
OK, I wanted to run it as external but when I use the Hazel "run shell script/other" action, the tagfiler.rb is grayed out and non-selectable. Same problem if I change extension to .sh
Any idea what I am missing here?