Page 1 of 1

Writing tags with xattr

PostPosted: 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.

Re: Writing tags with xattr

PostPosted: 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.

Re: Writing tags with xattr

PostPosted: 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..

Re: Writing tags with xattr

PostPosted: Tue May 16, 2017 3:58 pm
by Dave61
Thanks. I will have a look at that.