4

Update:
After the two answers so far I have moved the goalposts slightly. I need multiple selections & tabs - the existing answers; one has multi-select capability, the other gives me tabs, which I've realised is the way to go.


I decided the best way to keep track of a catalogue of published photographs without disturbing their original hierarchy was to drag aliases across to a separate location.

However, many use-cases require the original; they can't cope with having the alias itself dropped to, eg a web site, or Photos.app

Right click - Show Original insists on showing it inside the same window container, so going back to the alias folder loses its place, the selection is gone. In a large folder, this really tests your memory as to where you were up to.

Is there any way to force it to open in a new window, similar to Cmd/double-clicking a folder, thus keeping your place in the folder of aliases?

Currently on High Sierra 10.13.4

4
  • As you said, you "moved goalposts" thus invalidated the two answers as complete. Did you also, with the help of the answers here (copy/paste) submit your own and accepted that one as the answer to the question? And you feel ok with that?
    – boris42
    Commented Apr 29, 2018 at 6:18
  • I feel absolutely fine with that. As your attitude led me to believe you were not going to be further forthcoming, I went elsewhere & returned here to credit my sources & complete the circle by providing an accepted, accredited answer. You catch more flies with honey than vinegar.
    – Tetsujin
    Commented Apr 29, 2018 at 6:46
  • Oh no, I was just asking, me being new here to see how it works. Not catching, just learning. My last question should have been "Is this okay to do" because that's what I meant. Your combined code is short and to the point and a resource to all who learn.
    – boris42
    Commented Apr 29, 2018 at 11:04
  • Ah, OK - proves you can never read intent or inflection into text, my bad :) In terms of 'getting to the answer required' then yes. It was something i needed to achieve. My own problem was that I hadn't fully & clearly defined the requirements beforehand. The original solutions each had small but undesirable side-effects. The end result gives a very neat second window containing all the originals. Crediting the authors of each part in a new answer seemed the only fair way to combine it all in a single solution within Ask Different itself.
    – Tetsujin
    Commented Apr 29, 2018 at 16:11

3 Answers 3

4

I looked around and found an applescript (which can be turned into a shortcut) that does just want you want. Unfortunately, it's not super simple like it should be. It's better than nothing though, and you only need to do this once. It will save you time in the long run.

1) Open Automator.

2) Create new 'Service'

3) Set Service receives to 'no input' in 'Finder'

4) add 'Run applescript'

5) put this code inside it:

-- duplicateFinderTab.scpt
-- Uses a hacky workaroud to duplicate the frontmost Finder tab,
-- since Apple hasn't provided great AppleScript support for this.

----------------------------------------------
on run {}
    tell application "Finder"
        if (count of Finder windows) > 0 then set duplicate_me to target of front Finder window
        set _sel to the selection
    end tell

    new_tab()

    tell application "Finder"
        set target of front Finder window to duplicate_me
        select _sel
    end tell

    open_orig()

end run

----------------------------------------------
on new_tab()
    tell application "System Events" to tell application process "Finder"
        set frontmost to true
        tell front menu bar to tell menu "File" to tell menu item "New Tab"
            perform action "AXPress"
        end tell
    end tell
end new_tab
----------------------------------------------
on open_orig()
    tell application "System Events" to tell application process "Finder"
        set frontmost to true
        tell front menu bar to tell menu "File" to tell menu item "Show Original"
            perform action "AXPress"
        end tell
    end tell
end open_orig

6) save it (if you open a finder window, and have your alias selected, then go back to automator and hit 'run', then it will work at this point) -- Note: it may prompt you to add 'Automator' to the 'System Preferences' -> 'Security & Privacy' -> 'Accessibility' permissions.

7) in system preferences go to 'keyboard' -> 'shortcuts' -> 'services' -> 'whatever you named it' .. pick a shortcut (like "^-CMD-O").

Other things:

It may require you to do this once:

when finder is selected, in the menu,

'Finder' -> 'Services' -> 'whatever you named it'

or if it didn't appear:

'Finder' -> 'Services' -> 'Services Preferences..' -> check the box in system preferences that your application is called

There are other permission errors you might receive depending on how your system is set up, however, you should notice that the script DOES work when you hit 'run' on step 6 or after step 5. Just first select the file in the finder then swap over to the automator app and hit 'run'.

And if everything worked smoothly for you, the cmd-cntl-O shortcut should work for you, so you can do that shortcut, (which opens a new tab of the same selection), then right click and select 'show original'


Edit by OP
If you receive an error "com.automator.runner.xpc is not allowed assistive access" then the workaround is not obvious.
You cannot add com.automator.runner.xpc itself to Assistive Access, nor does adding Automator or Automator Runner help, however after a reboot the clue was that two errors were triggered, not just one.

enter image description here

Adding Finder itself to Assistive Access allowed the script to run.

1
  • Excellent, thank you! I added a tweak to your script to also show the original file in the new tab & some detail on working round Assistive permissions which took me a while to figure out. All now works beautifully.
    – Tetsujin
    Commented Apr 25, 2018 at 7:04
4

A much shorter and cleaner solution without UI scripting:

Open Automator, create a new Service, accepting files and folders from Finder, add a Run AppleScript action and type in following:

on run {input, parameters}
    repeat with aFile in input
        tell application "Finder"
            try
                set origFile to original item of aFile
                set aWindow to make new Finder window
                set aWindow's target to origFile's parent
                select origFile
            end try
        end tell
    end repeat
end run

Your screen should look something like this: reveal automator service

Save the Automator service as Reveal in New Window, then open System Preferences / Keyboard / Shortcuts / Services. Find the Reveal in New Window service, click Add Shortcut and type R. Your screen should look something like this:

services preferences

Close and try the service in Finder by selecting one or more alias(es) and pressing the chosen shortcut R. It works with multiple files, folders and can perform the Reveal even if some of the items are not actually aliases (hence the try/end try in the script).

4
  • Very neat! As it can handle multiple selection it can lead to a bit of window spray. Is it possible to change set aWindow to make new Finder window to open a new tab instead?
    – Tetsujin
    Commented Apr 25, 2018 at 10:03
  • @Tetsujin you can limit window spray by either using just the first item, or limit to a certain max number of items with a simple counter and an if statement. I can't immediately recall of a method to open tabs without keystroke scripting which makes it much more verbose. Also that wasn't in the original question. An upvote if you liked the solution?
    – boris42
    Commented Apr 25, 2018 at 10:20
  • How could I make this work on symbolic links? I don't use Aliases.
    – e40
    Commented Dec 22, 2018 at 1:51
  • Also, this one doesn't do anything for me. After pressing the key sequence, I see "Finder" in the menu bar flash, but that's it.
    – e40
    Commented Dec 22, 2018 at 2:09
3

With the help of StackOverflow & starting from the ideas presented in both the answers from brw59 boris42, I now have this, by user3439894

on run {input, parameters}
    set madeNewWindow to false
    repeat with i from 1 to count input
        tell application "Finder"
            if (kind of item i of input) is equal to "Alias" then
                set origFile to original item of item i of input
                if not madeNewWindow then
                    set aWindow to make new Finder window
                    set madeNewWindow to true
                else
                    my makeNewTab()
                end if
                set aWindow's target to origFile's parent
                select origFile
            end if
        end tell
    end repeat
end run

on makeNewTab()
    tell application "System Events" to tell application process "Finder"
        set frontmost to true
        tell front menu bar to tell menu "File" to tell menu item "New Tab"
            perform action "AXPress"
        end tell
    end tell
end makeNewTab

It combines what I thought I needed with what I actually needed, using both UI & non-UI scripting & presents me with one new window, nicely filled with tabs, all with one alias selected, so I can flip through the tabs & deal with each selection one at a time, then close afterwards, leaving my original window in place.

1
  • Looks like what I want, but I can't get this solution to do anything. I see "Finder" in the menu bar flash, but that's it. Ideas?
    – e40
    Commented Dec 22, 2018 at 2:14

You must log in to answer this question.

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