Your best friend for file transfer.

Fetch application logoFetch

Passing filenames in Automator (3 posts)

  • Started 16 years ago by Pmorgan
  • Latest reply 16 years ago from Pmorgan
  • Pmorgan Member

    I am trying to specify as subset of files to download from a server using Automator by passing the full path and filename from a Textedit document to Get Selected Fetch Items and Download Fetch Items.

    Automator flow appears to work but doesn't download correct file, but rather the first file in the directory specified in the Textedit line.

    Any suggestions would be greatly appreciated.

    Posted 16 years ago #

  • Jim Matthews Administrator

    The Get Selected Fetch Items action passes whatever items are selected in Fetch to the next action in the workflow.

    You need a way to convert the text in your TextEdit document into Fetch Items that the Download Fetch Items action can process. I would do that by first making sure that the lines in the TextEdit document are valid Fetch addresses, aka URLs. You can get the Fetch address of an item by selecting it in Fetch and choosing Copy Fetch Address from the Edit menu. The usual format for Fetch addresses is:

    ftp://username:@hostname/path/filename

    You can select multiple items and copy all the addresses at once.

    Then you want to add a Run AppleScript action to your workflow to convert each line of the TextEdit document into a Fetch Item. Here's the script you need:

    on run {input, parameters}

    set outputItems to {}
    set linecount to count of every paragraph of input
    repeat with lineIndex from 1 to linecount
    set aline to paragraph lineIndex of input
    if (offset of "ftp://" in aline) > 0 then
    tell application "Fetch"
    set newItem to properties of url aline
    end tell
    set outputItems to outputItems & {newItem}
    end if
    end repeat

    return outputItems
    end run

    Then you would put the Download Fetch Items action; you do not need a Get Selected Fetch Items action.

    Please let me know if this does what you need.

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 16 years ago #

  • Pmorgan Member

    Thank Jim. Worked like a charm.

    Posted 16 years ago #

Reply

  • Or nickname, if you prefer.
  • This will be kept confidential.
  • This is to ensure that you’re a person, not a spambot.