Finding stacks with spotlight
David Bovill
david at openpartnership.net
Tue Sep 2 10:21:19 EDT 2008
This function finds all your stacks on the hard disk, and optionally
searches for text or words in the file name. It's OSX only and can be done
in transcript but thats slower and avoids problems such as loading all the
stacks into memory:
function spotlight_FindStack fileBit, inFolder
/*
http://blog.clawpaws.net/post/2007/02/11/Making-OS-X-Fat-Binaries-with-Traditional-Tools
http://developer.apple.com/documentation/Carbon/Conceptual/SpotlightQuery/Concepts/QueryFormat.html
*/
put "(kMDItemKind = 'Revolution Stack')" into queryExpression
if fileBit is not empty then
replace (quote & "'") with empty in fileBit
get merge("(kMDItemDisplayName = '[[fileBit]]')")
put space & "&&" && it after queryExpression
end if
put "mdfind" && kwote(queryExpression) into someShell
-- put someShell
if inFolder is not empty then
shell_BashParamEscape inFolder
put space & "-onlyin" && inFolder after someShell
end if
return shell(someShell)
end spotlight_FindStack
--> Dependencies | spotlight_FindStack
-
function kwote string
return quote & string & quote
end kwote
on shell_BashParamEscape @someParam
replace space with ("\" & space) in someParam
replace "|" with ("\" & "|") in someParam
end shell_BashParamEscape
It's not fully tested - so feedback is welcome. Also I am trying to search
the contents of the stacks, scripts and or text. Originally Rev scripts
searchable with Spotliht but don't think this is the case any more?
kMDItemTextContent
Contains a text representation of the content of the document. Data in
multiple fields should be combined using a whitespace character as a
separator. An application's Spotlight importer provides the content of this
attribute.
Applications can create queries using this attribute, but are not able to
read the value of this attribute directly.
Value Type: CFString
Framework: CoreServices/CoreServices.h
Header: MDItem.h
Availability: Available in Mac OS X v10.4 and later.
More information about the use-livecode
mailing list