Skip to content

Instantly share code, notes, and snippets.

@tayiorbeii
Created November 2, 2022 06:25
Show Gist options
  • Save tayiorbeii/29d4afa976c10095b631532fc37a330e to your computer and use it in GitHub Desktop.
Save tayiorbeii/29d4afa976c10095b631532fc37a330e to your computer and use it in GitHub Desktop.
import "@johnlindquist/kit"
// Author: Taylor Bell
// Name: search by filename
// Shortcut: opt+f
// Description: Select files in Finder that contain a substring
let name = await arg()
await applescript(`
set folderpath to false
tell application id "com.apple.Finder" to tell (a reference to the ¬
front Finder window) to if it exists then tell its target as ¬
alias to set folderpath to its POSIX path
if folderpath = false then set folderpath to "~/Desktop"
tell application id "com.apple.SystemEvents" to tell the ¬
folder named folderpath to tell (every file whose ¬
name contains "${name}") to set filepaths to its path
tell application id "com.apple.Finder"
reveal the filepaths
activate
return the selection as alias list
end tell
`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment