user1625344 user1625344 - 2 months ago 25
AppleScript Question

Setting File Metadata with Applescript or Automator

I know how to set file keywords (com.apple.metadata:kMDItemKeywords) using a command line process that involves creating a plist, converting to binary and using xattr. It works but is painful. I'm hoping there is a better way.

Can anyone explain how to set file metadata using Apple's tools? Or point to websites that cover this?

All pointers appreciated.

oa- oa-
Answer

Try to modify the code below to fit your needs:

set aFile to choose file
set a to quoted form of POSIX path of aFile

do shell script "xattr -w com.apple.metadata:_kMDItemUserTags '(\"orange\\n6\",\"test\")' " & a

Happy keywording!