Spotlight¶
The Spotlight service searches files with the system index, as the Spotlight menu does. Access it via app.spotlight. Results are paths; files excluded in System Settings > Spotlight never appear.
app.spotlight.search("invoice kind:pdf")
app.spotlight.find_name("Visual Studio Code")
Methods¶
search(query, folder=None, limit=100, timeout=30.0)¶
Search names and contents. query is words as typed in Spotlight, such as "invoice kind:pdf", or a metadata query such as "kMDItemContentType == 'com.adobe.pdf'".
find_name(name, folder=None, limit=100, timeout=30.0)¶
Files whose name contains name, ignoring case.
| Parameter | Type | Description |
|---|---|---|
folder |
str \| PathLike |
Only search under this folder |
limit |
int |
At most this many paths. The search stops as soon as it has them |
timeout |
float |
Seconds to wait |