Your best friend for file transfer.

Fetch application logoFetch

Fetch and Apple Script (5 posts)

  • Started 10 years ago by Jason
  • Latest reply 10 years ago from Jason
  • Jason Member

    How can I download specific files with fetch using AppleScript? For example:

    FILE22222.txt
    FILE22233.txt
    FILE11122.txt
    FILE11133.txt

    I only want to download files that begin with FILE2*. Ideally only new files that start with FILE2*.

    Posted 10 years ago #

  • Jim Matthews Administrator

    Hi,

    You could set up an Automator workflow to do this, using the Get Specified Fetch Items action (to indicate which folder to download from), the Get Fetch Folder Contents action (to list the files in that folder), the Filter Fetch Items action (to pick out names starting with "FILE2"), and the Download Fetch Items action to do the download.

    Let me know if that doesn't do what you want.

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 10 years ago #

  • Jason Member

    Automater works great when it works every time, however if Fetch can not connect for some reason then the process stops leaving Fetch open. I need this to work unattended everyday twice a day and if it runs into a problem I need to be alerted via email. I can manage the errors in AppleScript. I just can't figure out how to filter the items to get only the files I need.

    If this is not something that can be done with Fetch within AppleScript then I'll work around it. I appreciate your help.

    Posted 10 years ago #

  • Jim Matthews Administrator

    It can definitely be done in AppleScript, it's just more work than Automator.

    Here's an AppleScript that downloads the files in the currently displayed folder if they start with "FILE2":

    tell application "Fetch"
    set allNames to name of every remote file of transfer window 1
    set matchedNames to {}
    repeat with eachName in allNames
    if (offset of "FILE2" in eachName) = 1 then
    set matchedNames to matchedNames & eachName
    end if
    end repeat
    if (count of matchedNames) > 0 then
    download remote file matchedNames
    end if
    end tell

    Does that help?

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 10 years ago #

  • Jason Member

    Thank you very much!! I see another sale of your software coming in the near future.

    Posted 10 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.