Spotlight problems

Discussion in 'Mac Programming' started by nelly22, Mar 29, 2013.

  1. macrumors regular

    Joined:
    Sep 29, 2009
    #1
    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 *****"
     
  2. macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2

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

    Attached Files:

  3. thread starter macrumors regular

    Joined:
    Sep 29, 2009
    #3
    Thanks.

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

    This don't work:
    do shell script "mdfind beatles *****"
     
  4. macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #4
    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
     

    Attached Files:

  5. thread starter macrumors regular

    Joined:
    Sep 29, 2009
    #5
    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?
     
  6. macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #6
    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.
     

Share This Page