PDA

View Full Version : Spotlight problems




nelly22
Mar 29, 2013, 09:01 AM
If i open Spotlight window in Finder and make Spotlight search, is there any way to get that search query as raw query string, so i can then put it to "do shell script" in my AppleScript?

How i can search songs with rating 5?

do shell script "mdfind beatles *****"



kryten2
Mar 29, 2013, 03:45 PM
If i open Spotlight window in Finder and make Spotlight search, is there any way to get that search query as raw query string, so i can then put it to "do shell script" in my AppleScript?

How i can search songs with rating 5?

do shell script "mdfind beatles *****"


Save your search, get info on your search. Look at the query.

nelly22
Mar 30, 2013, 12:05 AM
Thanks.

So how i can search songs with rating 5 in do shell script?

This don't work:
do shell script "mdfind beatles *****"

kryten2
Mar 30, 2013, 01:00 PM
Thanks.

So how i can search songs with rating 5 in do shell script?

This don't work:
do shell script "mdfind beatles *****"

It seems like mdls shows the value of the kMDItemStarRating attribute as (null) when set in iTunes. Don't know if this is a bug or supposed to happen but I noticed this on SL and ML and from what I've read this also occurs on Tiger and Leopard. See the link for the workaround. I suggest you also read some documentation or man pages for the mdls and mdfind command.

Info : http://hints.macworld.com/article.php?story=20110314131100623

nelly22
Mar 31, 2013, 03:08 AM
Info : http://hints.macworld.com/article.php?story=20110314131100623

Thanks!!!

Your link is what i was looking for.

That page has this long script. Do i need to use it or can i just set rating with that one line script?

Longer script has these "Check for existence of xattr" and "Check for at least two arguments". What these do?

kryten2
Mar 31, 2013, 04:26 PM
Thanks!!!

Your link is what i was looking for.

That page has this long script. Do i need to use it or can i just set rating with that one line script?

Longer script has these "Check for existence of xattr" and "Check for at least two arguments". What these do?

It's up to you to decide what you want to use. "Check for existence of xattr" does exactly what it says. There's no point in continuing the script if xattr isn't there to be used. Try running the script with only one argument eg only the rating argument and no file argument and see what happens. You also might want to read up on shell scripting.