Skip to content

Instantly share code, notes, and snippets.

@tzarskyz
Created April 29, 2013 08:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzarskyz/5480367 to your computer and use it in GitHub Desktop.
Save tzarskyz/5480367 to your computer and use it in GitHub Desktop.
-- get path of Finder window
tell application "Finder"
try
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
try
set posix_matches to do shell script "ls -d " & ¬
quoted form of start_path & text returned of result
on error
return
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
activate
select matches
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment