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 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.
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:
e/^(?>(?!\.mp4).)+
This will select everything but items whose name contains β.mp4β.
-Chris
I know this is an old topic, but here's my "contribution"
I found the exact same script when I Googled this same question and some comments said that this script works well on a folder with maybe a few dozen files, but not when there are maybe 1,000 or so (they said they got a timeout error).
I just tested it with a folder with close to 400 files and it worked, so maybe macOS somehow "fixed" this, maybe it gets worse the more files you have, etc, but just wanted to leave it here in case someone get that error, it means it's "expected" somehow.
For just a few files, I think that running a script takes "longer" than using the manual approach: