Previous Index Next

BridgePlus.framework, SMSForder Class Methods

Category

URL and File related methods

Method

runSpotlightQuery:queryValues:inFolders:error:

Summary

As above, but allowing the use of placeholder strings in the query string. For example, a query string of "kMDItemFSCreationDate > %@" could be used with queryValues of {someDate}. Where queryValues should contain dates, both NSDates and AppleScript dates are accepted.

Signature

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

Parameters

queryString = valid Spotlight query string with one or more %@ placeholders

queryValues = list of values for placeholders

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:"kMDItemContentCreationDate > %@" queryValues:{(current date) - 10 * days} 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:"kMDItemContentCreationDate > %@" queryValues:{} inFolders:{(path to desktop)} |error|:(reference)

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

--> error number -10000  Insufficient arguments for conversion characters specified in format string.



Click here to open script in a script editor