Skip to content

Instantly share code, notes, and snippets.

@tayiorbeii
Created October 26, 2022 16:06
Show Gist options
  • Save tayiorbeii/4d09d1f4263a235351cd1c15e8343592 to your computer and use it in GitHub Desktop.
Save tayiorbeii/4d09d1f4263a235351cd1c15e8343592 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