lselect 1.1anoved.net logo

Make Complex Finder Selections

example lselect dialog

lselect is an AppleScript that lets you select files in the Finder using shell glob syntax as you would to list files with ls.

Demonstration

Download

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.

Changes

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.

Installation

Suggested installation location: ~/Library/Scripts/Applications/Finder/

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.

Usage

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.
[abc]
Match any one character in abc. A range of characters may be specified as a-z, or 0-9, for example.
[^abc]
Match any one character not in abc.
{a,b,c}
Matches any of the strings a, b, or 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.

Similar Scripts & Utilities