Is there any way to invert file selections on Mac OS X like we do it on Windows?

15

4

I'm Windows OS lover but recently I've got Mac Notebook as a gift. So now I just want to know if is there any option under Edit that lets me invert my selection? For example, I select only files that I don’t want and once I click on Invert Selection using Edit option, all the files that I didn’t select will be selected instead.

Is there any similar option in OS X too?

Nicks

Posted 2012-11-01T07:39:18.640

Reputation: 93

Answers

24

The key you're looking for is Cmd.

Select the files – any view should work – then move with the mouse cursor to the empty space next to the file list. Hold Cmd and drag to invert the selection:


If you don't want to use the mouse, an alternative way would be to use AppleScript instead. Open up Automator.app, create a new Service. From the left pane, drag Run AppleScript to the right, and paste the following:*

on run {input, parameters}

  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

  return input
end run

Set this service to receive No Input from Finder.app. Like this:

Save this service as Invert Selection. Then, head to System Preferences » Keyboard » Keyboard Shortcuts, and add your shortcut to the service, for example ShiftCmdI:

Now, select any files in Finder and press the shortcut to invert the selection.

* I found this on the Apple Mailing Lists, no idea who wrote it though.

slhck

Posted 2012-11-01T07:39:18.640

Reputation: 182 472

1The cmd trick is awesome. – entropid – 2014-11-18T00:26:48.170

I have tried this solution on Yosemite 10.10. The script is working but can't use this keyboard shortcut as it conflicts with the built-in iCloud keyboard shortcut. I have tried many other keyboard shortcut but couldn't run the script as a service. – politicus – 2017-09-05T11:07:00.137

You have to write a script and do all this crap on a mac to do something as mundane as inverting a selection? Which is really common because you could have a folder of 5000 pictures, and you perhaps just want to keep 5 of them? – Muhammad bin Yusrat – 2020-02-15T11:55:26.033

If the script is run after opening a new window, it usually selects all files because of this bug.

– Lri – 2012-11-02T11:19:09.583

Your script does not scale all to well. Works fine for a folder with <50 items, but for a folder with 1500 items it resulted in a timeout :-( My use case: I made aliases to desired files within a folder of 1500 files. I select all aliases, press CMD-R (reveal originals), and then would like to invert the selection, to then erase the needless files. Workaround: Move the selection into a temporary folder, delete the remaining undesired files, move the desired files back. – porg – 2014-02-25T20:37:16.877

@porg Well, who has 1500 items in a folder! :) But yeah, AppleScripts don't scale that well, you're right. – slhck – 2014-02-25T20:46:37.040

Would there be a possibility to save the items as a something less resource intensive than an alias list, i.e. a POSIX file list or the like? – porg – 2014-02-26T08:41:48.987

0

On windows there is another way to do this.

invert select

It should work for Mac too.

Prasanth

Posted 2012-11-01T07:39:18.640

Reputation: 512

3Parasanth's answer does actually work on mac, you just swap ctrl for cmd – Craig – 2014-08-25T09:18:27.633

This doesn't work. If you hold ctrl and click, it will pop up the context menu, since ctrl-click emulates a secondary mouse button. – slhck – 2012-11-01T14:08:45.777

0

It's not quite the same, but there's a more natural way to do this sort of thing on a Mac: rather than selecting the files you don't want and then inverting the selection, select all files (Edit menu > Select All, or Command-A), then deselect the files you don't want with Command-click.

Gordon Davisson

Posted 2012-11-01T07:39:18.640

Reputation: 28 538

I can confirm that this does not work on Catalina 15.1.3 at least. – Muhammad bin Yusrat – 2020-02-15T11:56:32.817