Search code examples
applescriptautomator

Automator throws error on download, but download still completes?


I have a workflow, that downloads files from an FTP to my computer, using transmit and automator.

The action in automator looks like this:

Image of the action

The information for this action is correct, and the files of the remote file path are downloaded to my computer.

However, a 1/3rd of the way through the download (~200 files), automator throws an error:

Image of the error message

The download still continues, but the error stops automator from doing the rest of the workflow.

So my question is: How can I solve this error, or at least make the workflow continue after the error is displayed?


Solution

  • There is a way to have Automator continue on with the workflow without timing out. With AppleScript, If you wrap the download command within a with timeout of 1000 command (1000 is in seconds. Use whatever number you think will work), the script will now wait for up to 1000 seconds for the download command to complete, instead of the default of 120 seconds, before timing out or moving on to its next command.

    So instead of adding the Automator Transmit Download action to your Automator Workflow, you can insert a Run AppleScript command to your Workflow


    For example let's say you want to download every currently selected file on the remote browser of the current tab in Transmit.app without timimg out, you would insert a Run AppleScript command to your Workflow and insert this following AppleScript code. (obviously editing the properties in the code to suit your needs.)

    property downloadLocation : POSIX path of (path to desktop)
    property filesToDownload : missing value
    
    tell application "Transmit"
        tell its document "Transmit"
            set selectedFiles to a reference to selected browser items of ¬
                (get remote browser of current tab)
            if (count of selectedFiles) > 0 then
                set filesToDownload to path of selectedFiles
            else
                return
            end if
            repeat with thisFile in filesToDownload
                with timeout of 1200 seconds
                    download remote browser of current tab item at path thisFile to ¬
                        downloadLocation with resume mode resume
                end timeout
            end repeat
        end tell
    end tell
    

    enter image description here