AppleScript to show package contents of hidden original of alias I'm attempting to build an Automator workflow (which will be saved as a Service, so that I can both access it from contextual menus and invoke it with a keyboard shortcut), that will function much like the Finder's built-in "Show Package Contents" command, but which will additionally accept a package's alias as input. The service will satisfy the following:

It will only be available when the Finder's selection consists of a package or a package's alias.

Rather than show the contents of the package directory itself like the built-in command does, the Service will show the contents of the "Contents" directory (if it exists), located immediately within the package directory.

If the Finder's selection is a package or alias on the desktop, the Contents directory should be opened in a new Finder window. Otherwise, the Contents directory should be opened in the Finder window containing the selection.

My approach has been to have the script first determine whether the file is an Alias, and if it is, to tell the script to show the contents of the original. If the file is not an alias, I'd like to tell the script to simply show the contents of the input.

Excluding the possibility of an alias as input and assuming the input-package is selected in a Finder window, I can successfully write a script that shows the contents of the package's contents folder in the same window:

on run {input, parameters}
    set my_output to {}
    repeat with oneItem in input
        tell application "Finder" to set target of window 1 to ((oneItem as text) &amp; "Contents")
end repeat
return input
end run


When I try to set up an "if...then...else" scheme, I fail.

I'm using the latest versions of all relevant software.
You can try something like this:

   on run {input, parameters}
    tell application "Finder"
        repeat with oneItem in input
            if kind of oneItem = "Alias" then set oneItem to oneItem's original item
            set contentsPath to (oneItem as text) &amp; "Contents"
            if oneItem's container as text = (path to desktop as text) then
                open contentsPath
            else
                set target of window 1 to contentsPath
            end if
            activate
        end repeat
    end tell
end run


You may also want to include a test to make sure the input is the expected type.