Previous Index Next

BridgePlus.framework, SMSForder Class Methods

Category

URL and File related methods

Method

runSpotlightQuery:inFolders:error:

Summary

Conduct a Spotlight metadata search. The query string needs to be a valid Spotlight query, such as "kMDItemFSInvisible = YES". listOfFilesPathsURLsOrQueryScopeConstants can contain aliases, files, HFS paths, POSIX paths or NSURLs, as well as query scope constants such as 'current application's NSMetadataQueryLocalComputerScope'. Returns an array of POSIX paths, or missing value if there is an error.

Signature

+ (NSArray *)runSpotlightQuery:(NSString *)queryString inFolders:(NSArray *)listOfFilesPathsURLsOrQueryScopeConstants error:(NSError *__autoreleasing *)outError

Parameters

queryString = valid Spotlight query string

listOfFilesPathsURLsOrQueryScopeConstants = aliases, files, HFS paths, POSIX paths or NSURLs, as well as query scope constants such as 'current application's NSMetadataQueryLocalComputerScope'

outError = missing value or reference

Result

Array of POSIX paths

Availability

Version 1.3.0

Notes

If you set outError to reference, the result will be a list of two items. If there is no error, the first item will be the result of the method and the second will be missing value. If there is an error, the first item will be missing value and the second item with be an NSError.

Sample

use scripting additions

use framework "Foundation"

use script "BridgePlus"

load framework


set theResult to current application's SMSForder's runSpotlightQuery:"kMDItemContentTypeTree CONTAINS 'public.image'" inFolders:{(path to desktop)} |error|:(missing value)

ASify from theResult

--> <list of image files on desktop, searching recursively>

theResult as list

--> <list of image files on desktop, searching recursively>


set {theResult, theError} to current application's SMSForder's runSpotlightQuery:"invalid query" inFolders:{(path to desktop)} |error|:(reference)

if theResult = missing value then error (theError's localizedDescription() as text)

--> error number -10000  Unable to parse the format string "invalid query"



Click here to open script in a script editor