Update: Now located at https://github.com/anoved/Finder-Scripts/tree/master/LSelect
Make Complex Finder Selections
lselect is an AppleScript that lets you select files in the Finder using shell glob syntax as you would to list files with ls. For an animated illustration of how it works, view this short screencast.
See my comments in the script for more information about how it works and how it could stand to be improved. Other comments and discussion at Mac OS X Hints.
- lselect.scpt.zip 1.1 (24k) “Compiled” version
- lselect-toolbar-app.zip 1.1 (15k) Thanks to Henrik Nyh!
- lselect.applescript 1.1 (5k) Source
Version 1.1 improves compatibility with the Finder’s column view. One known remaining issue with column view is that if the last item in the list of matches is a directory, its contents will be revealed and other matches will lose selection. This may be a Finder bug.
Suggested installation location:
The script can be invoked with the standard Mac OS X Script Menu, but I’ve found FastScripts to be a preferable alternative, primarily because of the ease with which reliable keyboard bindings can be assigned. I use ⌘G.
Actual usage scenarios exist, but if you have to ask what they are, this isn’t the tool for you.
Enter a glob pattern in the indicated field. This pattern will be compared against filenames in the current directory, and any complete matches will be selected. Briefly:
- Match any one character.
- Match any sequence of zero or more characters.
- Match any one character in
abc. A range of characters may be specified as
0-9, for example.
- Match any one character not in
- Matches any of the strings
c, which may consist of more than one character each.
Spaces and certain other punctuation must be escaped with a backslash. For example, a folder called “
Jim's Stuff” would be matched by the pattern “
Jim\'s\ Stuff”. This requirement is not ideal. Please fix it!
Click Select Matches to select only those files that match the search pattern. If no files match, nothing will be selected. Click Add Matches to add any matches to the current selection. If Cancel is clicked the current selection will not be modified.