2

The Applescript below looks at the front open finder window, finds the file type of a file that is selected, and then highlights all files of that file type. I.e., if a finder window has a mix of .jpg, .png and .webp files, the script finds the one file that is selected (such as a .jpg) and then selects all .jpg files.

try
    tell application "Finder" to set the source_folder ¬
        to (folder of the front window) as alias
on error -- no open folder windows
    --set the source_folder to path to desktop folder as alias
    --problem is a window can be open but out of focus
    beep
end try

tell application "Finder"
    set selectionList to {} & selection as list
    set selectedCount to count items in selectionList

    if selectedCount > 0 then
        set nameExtension to name extension of item 1 in selectionList
        select (every item where name extension ¬
            is nameExtension) of (folder source_folder)
    end if
end tell

How would I modify this so it works with an application like the FTP client Transmit? Transmit is Applescript aware and appears in the Applescript Dictionary.

Of course, simply changing tell application "Finder" to tell application "Transmit" doesn't work, since source_folder throws an error as it's looking for a finder window and not an application window.

  • What are you wanting to do? If you are talking about passing the Finder selection to Transmit you could still use the Finder, otherwise you would need to look in the Transmit scripting dictionary to see if it provides any selection terminology. – red_menace Sep 12 '19 at 19:35
1

Here is the scripting definition file for the latest version of Transmit, downloaded today from the Panic homepage.

Transmit.app AppleScript Terminology

Conclusion: Having read through the terminology and running a few brief tests in Script Editor to pass the time in an Apple Store, I highly suspect it is not possible to use AppleScript to select files in a Transmit file browser.

Justification: Most notably, there is no command that is called select, or with a name indicative of a similar function. Also lacking is any property belong to any element or class object that sounds like selected or selection.

There is a class of object belonging to a file browser called a selected browser item. This, as you may be able to guess, is an object reference to the currently selected file(s) in the file browser. Therefore, it is possible to retrieve a list of files currently selected:

tell application id "com.panic.Transmit"
    tell the front document
        if not (exists) then return null
        tell the current tab
            tell the local browser
                get the name of every selected browser item
            end tell
        end tell
    end tell
end tell

Any attempts to set the selected browser items either collectively or individually by index was unsuccessful. Invoking the make command to create a new selected browser item also failed.

Sorry that this might not be the answer you were hoping for.

| improve this answer | |
  • Thanks for your help; I need to learn how to use the script dictionaries. And I'll need to find another way to select files, I guess manually :( – BlueDogRanch Sep 14 '19 at 14:20

You must log in to answer this question.

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