Imported from the Apple Support Forums via the Wayback Machine 🔗
when i run mdls in terminal with -raw option it does not return correct results while it does do so when called from applescript. I added a spotlight comment "me" to my home directory. if I run
mdls -name kMDItemFinderComment ~
in terminal it returns
kMDItemFinderComment = "me"
but
mdls -name kMDItemFinderComment -raw ~
returns nothing.
on the other hand when I run
do shell script "mdls -name kMDItemFinderComment -raw ~"
Imported from the Apple Support Forums via the Wayback Machine 🔗
I think it has to do with the ASCII null character that is used as a separator in the -raw results. Piping the results to *xargs -0* shows the comment for me, so there is probably just a difference in the way the null character is handled by the shell vs *do shell script*.
0
Apple Support Community member·
Imported from the Apple Support Forums via the Wayback Machine 🔗
that's it! thanks a lot. I still don't understand though why it works with some spotlight data but not other. for example,
mdls -name kMDItemLastUsedDate -raw ~
works without piping to xargs. it seems that in this case the leading null character in not there (but the trailing is).