I was wondering why I could not add common metadata with xattr after losing metadata processing pictures with sips
tell application "Finder" to set sel to item 1 of (get the selection) as text
set {pxH, pxW, getDpi} to get_pictprops(sel)
return do shell script "mdls '" & POSIX path of sel & "'"
#do shell script "xattr -w com.apple.metadata:_kMDItemUserTags '(\"orange\\n6\",\"test\")' " & a
do shell script "xattr -w com.apple.metadata:kMDItemPixelHeight '" & pxH & "'" & quoted form of POSIX path of sel
do shell script "xattr -w com.apple.metadata:kMDItemPixelWidth '" & pxW & "'" & quoted form of POSIX path of sel
do shell script "xattr -w com.apple.metadata:kMDItemResolutionHeightDPI '" & getDpi & "'" & quoted form of POSIX path of sel
do shell script "xattr -w com.apple.metadata:kMDItemResolutionWidthDPI '" & getDpi & "'" & quoted form of POSIX path of sel
on get_pictprops(getFile)
#get measures for single images
set px to POSIX path of (getFile as text)
set get_pp to paragraphs -2 thru -1 of (do shell script "sips -g pixelHeight -g pixelWidth '" & POSIX path of getFile & "'")
set {pxH, pxW} to {word -1 of item 1 of get_pp, word -1 of item 2 of get_pp}
set getDpi to (word -1 of (do shell script "sips -g dpiHeight '" & px & "'") as integer) div 1000
return {pxH, pxW, getDpi}
end get_pictprops
(*
kMDItemPixelHeight = 2000
kMDItemPixelWidth = 1815
kMDItemProfileName = \"sRGB IEC61966-2.1\""
kMDItemResolutionHeightDPI = 300
kMDItemResolutionWidthDPI = 3
*)