Writing tags with xattr

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

Moderator: Mr_Noodle

Writing tags with xattr Sun Apr 16, 2017 7:59 am • by Dave61
Not quite the right place for this query, but I hope some kind soul will point me in the right direction.

I use tags to automate filing. One set of files uses macOS tags (no problem) but I have another set of files that I need a separate set of tags for, which I am using OpenMeta. Some of the second set could be tagged automatically using Hazel, indeed I have this working when one tag is relevant:

Code: Select all
if
  comment contains "keyword"
then run embedded script
  xattr -w com.apple.metadata:kMDItemOMUserTags Tag1 $1


But, I have a problem when more than one tag is relevant: I cannot find the correct syntax for adding two (or more) tags.
Dave61
 
Posts: 114
Joined: Tue Jul 10, 2012 4:56 pm

Re: Writing tags with xattr Mon Apr 17, 2017 10:46 am • by Mr_Noodle
This is a bit outside of the support I can give, as it seems more like a shell/OpenMeta issue. I will point out that there is an openmeta commandline program which you may want to use instead.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Writing tags with xattr Thu May 11, 2017 11:31 pm • by smccreary
Dave61 wrote:Not quite the right place for this query, but I hope some kind soul will point me in the right direction.

I use tags to automate filing. One set of files uses macOS tags (no problem) but I have another set of files that I need a separate set of tags for, which I am using OpenMeta. Some of the second set could be tagged automatically using Hazel, indeed I have this working when one tag is relevant:

Code: Select all
if
  comment contains "keyword"
then run embedded script
  xattr -w com.apple.metadata:kMDItemOMUserTags Tag1 $1


But, I have a problem when more than one tag is relevant: I cannot find the correct syntax for adding two (or more) tags.



Hey Dave61, I'm very new with Scripting and command line syntax - and also have interest in a file naming/strategy using tags.. I have tested the following in Terminal and verified the multiple tag write with GetInfo. Try this:

xattr -w com.apple.metadata:_kMDItemUserTags '("this tag","yestag")' MadeInCanada.jpeg

(Not exactly sure, seems _kMDItemUserTags is expecting an array of string)

Hope this helps you..
Regards..
smccreary
 
Posts: 2
Joined: Thu May 11, 2017 11:10 pm

Re: Writing tags with xattr Tue May 16, 2017 3:58 pm • by Dave61
Thanks. I will have a look at that.
Dave61
 
Posts: 114
Joined: Tue Jul 10, 2012 4:56 pm


Return to Support