Opening File in Finder


Gerriet M. Denkmann
 

I want to have a Finder window with “/a/hugeFolder/someThin"g selected.

[ NSWorkspace.sharedWorkspace openFile: @“/a/hugeFolder/someThing” withApplication: @“Finder" ]

results in an AlertPanel: “There is no application to open “someThing””.

But I do *not* want to open “someThing”, I just want it selected in Finder.

How to do this?

AppleScript comes to mind; but I am terrible bad at AppleScript.

Gerriet.


Quincey Morris
 

So, doesn’t NSWorkspace’s activateFileViewerSelecting method do that?

On Nov 8, 2017, at 10:54 , Gerriet M. Denkmann <g@...> wrote:

But I do *not* want to open “someThing”, I just want it selected in Finder.


Gerriet M. Denkmann
 

On 9 Nov 2017, at 02:03, Quincey Morris <quinceymorris@...> wrote:

So, doesn’t NSWorkspace’s activateFileViewerSelecting method do that?
It does indeed. Thanks very much for telling me.

On Nov 8, 2017, at 10:54 , Gerriet M. Denkmann <g@...> wrote:

But I do *not* want to open “someThing”, I just want it selected in Finder.
Kind regards,

Gerriet.


Andy Lee
 

Hi Gerriet,

Try this:

BOOL didSelect = [[NSWorkspace sharedWorkspace] selectFile:filePath
inFileViewerRootedAtPath:containingDirPath];

-Andy

On Nov 8, 2017, at 1:54 PM, Gerriet M. Denkmann <g@...> wrote:

I want to have a Finder window with “/a/hugeFolder/someThin"g selected.

[ NSWorkspace.sharedWorkspace openFile: @“/a/hugeFolder/someThing” withApplication: @“Finder" ]

results in an AlertPanel: “There is no application to open “someThing””.

But I do *not* want to open “someThing”, I just want it selected in Finder.

How to do this?

AppleScript comes to mind; but I am terrible bad at AppleScript.

Gerriet.


Andy Lee
 

Oh wow, I didn't know about that method -- perhaps because my code predated 10.6. :)

--Andy

On Nov 8, 2017, at 2:03 PM, Quincey Morris <quinceymorris@...> wrote:

So, doesn’t NSWorkspace’s activateFileViewerSelecting method do that?

On Nov 8, 2017, at 10:54 , Gerriet M. Denkmann <g@...> wrote:

But I do *not* want to open “someThing”, I just want it selected in Finder.


Quincey Morris
 

On Nov 8, 2017, at 11:05 , Andy Lee <aglee@...> wrote:

perhaps because my code predated 10.6. :)

Perhaps. :)



Quincey Morris
 

Oops, sorry, that was weird. Mail sent that message when I just closed the window, which wasn’t what I intended to happen.

I was in the process of composing an extremely witty response, but it wasn’t coming out witty at all. Luckily I succeeded in deleting the extremely unwitty text before Mail decided to send the rest of the message.

On Nov 8, 2017, at 14:27 , Quincey Morris <quinceymorris@...> wrote:

On Nov 8, 2017, at 11:05 , Andy Lee <aglee@...> wrote:

perhaps because my code predated 10.6. :)

Perhaps. :)

Feel free to insert your own extremely witty response here.