Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 29, 2013, 09:01 AM   #1
nelly22
macrumors regular
 
Join Date: Sep 2009
Spotlight problems

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 *****"
nelly22 is offline   0 Reply With Quote
Old Mar 29, 2013, 03:45 PM   #2
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
Quote:
Originally Posted by nelly22 View Post
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.
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2013-03-29 at 21.32.35.png
Views:	23
Size:	102.9 KB
ID:	405220  
__________________
Space Corps Directive 34124
kryten2 is offline   0 Reply With Quote
Old Mar 30, 2013, 12:05 AM   #3
nelly22
Thread Starter
macrumors regular
 
Join Date: Sep 2009
Thanks.

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

This don't work:
do shell script "mdfind beatles *****"
nelly22 is offline   0 Reply With Quote
Old Mar 30, 2013, 01:00 PM   #4
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
Quote:
Originally Posted by nelly22 View Post
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.ph...10314131100623
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2013-03-30 at 18.39.51.png
Views:	13
Size:	53.3 KB
ID:	405377   Click image for larger version

Name:	Screen Shot 2013-03-30 at 18.27.31.png
Views:	8
Size:	73.8 KB
ID:	405378  
__________________
Space Corps Directive 34124
kryten2 is offline   0 Reply With Quote
Old Mar 31, 2013, 03:08 AM   #5
nelly22
Thread Starter
macrumors regular
 
Join Date: Sep 2009
Quote:
Originally Posted by kryten2 View Post
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?
nelly22 is offline   0 Reply With Quote
Old Mar 31, 2013, 04:26 PM   #6
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
Quote:
Originally Posted by nelly22 View Post
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.
__________________
Space Corps Directive 34124
kryten2 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
EXS / spotlight indexing problems in mavericks? Leekenn Digital Audio 1 May 2, 2014 10:08 AM
iPhone: Really strange problems with evasi0n7 mobile substrate / spotlight respring. D: iParis Jailbreaks and iOS Hacks 15 Dec 25, 2013 02:24 AM
How to get spotlight to work properly (and other problems) Ckar MacBook Pro 15 Dec 6, 2013 02:46 PM
Problems with Applications Names (in Spotlight) macman161 OS X 10.8 Mountain Lion 4 Feb 6, 2013 05:40 PM
Spotlight Problems russsion Mac OS X 10.7 Lion 3 Jun 21, 2012 03:45 PM

Forum Jump

All times are GMT -5. The time now is 08:08 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC