Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nelly22

macrumors 6502
Original poster
Sep 29, 2009
366
5
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

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
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.
 

Attachments

  • Screen Shot 2013-03-29 at 21.32.35.png
    Screen Shot 2013-03-29 at 21.32.35.png
    102.9 KB · Views: 94

nelly22

macrumors 6502
Original poster
Sep 29, 2009
366
5
Thanks.

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

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

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
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
 

Attachments

  • Screen Shot 2013-03-30 at 18.39.51.png
    Screen Shot 2013-03-30 at 18.39.51.png
    53.3 KB · Views: 84
  • Screen Shot 2013-03-30 at 18.27.31.png
    Screen Shot 2013-03-30 at 18.27.31.png
    73.8 KB · Views: 79

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.