Solved: Copy Finder tags from an encapsulating folder

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

Moderator: Mr_Noodle

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
Last edited by DC1 on Sat Jul 19, 2014 8:36 am, edited 1 time in total.
DC1
 
Posts: 5
Joined: Tue Jul 15, 2014 2:59 pm

Already answered in the other thread but in short, you'll probably have to use a script for that.
Mr_Noodle
Site Admin
 
Posts: 11866
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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.
DC1
 
Posts: 5
Joined: Tue Jul 15, 2014 2:59 pm


Return to Support