Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Select files by glob
-- get path of Finder window
tell application "Finder"
set finder_window to window 1
on error
error "There are no Finder windows"
end try
set start_path to POSIX path of (target of window 1 as alias)
end tell
-- get user input
display dialog "Glob expression" default answer "*.md"
-- get matching files
set posix_matches to do shell script "ls -d " & ¬
quoted form of start_path & text returned of result
on error
end try
-- convert each path string to alias
set matches to {}
repeat with match in paragraphs of posix_matches
set matches to matches & (POSIX file match)
end repeat
-- select the matches
tell finder_window
select matches
end tell

This comment has been minimized.

Copy link

commented Oct 3, 2012

This is great! Any way to make it case-insensitive?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.