Inverse selection in Finder

I use @ccstone’s excellent macro to select files in a folder in Finder.

But sometimes I then would like to inverse the selection.

Does anybody know of a way to do this in Finder?

I found this in a Google search, and it appears to work:

tell application "Finder"
    set inverted to {}
    set fitems to items of window 1 as alias list
    set selectedItems to the selection as alias list
    repeat with i in fitems
        if i is not in selectedItems then
            set end of inverted to i
        end if
    end repeat
    select inverted
end tell

This is awesome. I don’t know what I need it for but I am saving it.

Thanks, Dan.

I tried with Google, but did not find what I needed.

Need to practise my Google Fu.

1 Like

It’s really interesting what you find when you test a search such as β€œInverse selection in Finder”

This is what I found…


Great! I never noticed this. Thanks for finding.

This β€œCommand Inverting Selection” actually dates back to MacPaint inverting pixels when drawing with the Command key down I believe.

And it works in Keyboard Maestro too.


Hey Christian,

I’ve wanted to do this on occasion, but I can’t point to a specific use-case at the moment.

More often I want to select everything except items that contain a specific string.

In my macro that Jimmy cites above you can do some magic with a regular expression to accomplish that:


This will select everything but items whose name contains β€œ.mp4”.