Page 1 of 1

Solved: Copy Finder tags from an encapsulating folder

PostPosted: Wed Jul 16, 2014 1:54 pm
by DC1
The situation:

A drop folder is tagged with some Finder tags, i.e. (business) (bills) (unpaid). Any file dropped into that folder should get the same tags plus a tag (inbox) and then stored away into an archive.

(inbox) tagging and archiving is easy, but how do I get the tags of the encapsulating folder ?

Thanks,
DC

Re: Copy Finder tags from an encapsulating folder

PostPosted: Thu Jul 17, 2014 11:21 am
by Mr_Noodle
Already answered in the other thread but in short, you'll probably have to use a script for that.

Re: Solved: Copy Finder tags from an encapsulating folder

PostPosted: Sat Jul 19, 2014 8:44 am
by DC1
The solution is a bash shell script:
Code: Select all
myPath=$(dirname $1)
xattr -wx com.apple.metadata:_kMDItemUserTags \
"$(xattr -px com.apple.metadata:_kMDItemUserTags $myPath)" $1

The first line extracts the directory path from the current file selected by Hazel.
The third line gets the tags of the directory and places them into a temporary pipe.
The second line takes the tags of the temporary pipe and applies them to the current Hazel file.

Second and third line are one shell command, separated for readability and connected by "\" at the end.