Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 14 down vote accepted

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.

share|improve this answer
    
Thank you so much. This is what I'm looking for. – Nicks Nov 2 '12 at 5:51
    
If the script is run after opening a new window, it usually selects all files because of this bug. – user495470 Nov 2 '12 at 11:19
    
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 Feb 25 '14 at 20:37
    
@porg Well, who has 1500 items in a folder! :) But yeah, AppleScripts don't scale that well, you're right. – slhck Feb 25 '14 at 20:46
    
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 Feb 26 '14 at 8:41

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.

share|improve this answer
    
Thanks! Got it! – Nicks Nov 2 '12 at 5:51

On windows there is another way to do this.

invert select

It should work for Mac too.

share|improve this answer
    
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 Nov 1 '12 at 14:08
    
Parasanth's answer does actually work on mac, you just swap ctrl for cmd – Craig McArthur Aug 25 '14 at 9:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .