Your best friend for file transfer.

Fetch application logoFetch

Scripting Fetch to download latest file (16 posts)

  • Started 3 years ago by Tim Hodge
  • Latest reply 3 years ago from Jim Matthews
  • Tim Hodge Member

    I have a series of folders.
    I would like to automate the newest files located in each folder.
    Can someone suggest a resource or Automator Script for me?

    My remote folder have names such as 0423, D234, D980, etc.
    Clients ftp files into these folders on a regular basis.
    What I need to download is their latest file.
    Any help would be appreciated.

    Posted 3 years ago #

  • Jim Matthews Administrator

    Hi,

    I'd be happy to help. I have an AppleScript that will watch server folders, and send you an email whenever a new file appears in one of them. Would that serve your needs?

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 3 years ago #

  • Tim Hodge Member

    That would be a big help Jim. My clients upload files daily or weekly into about 100 folders on my server. Each client has their own folder. Could this script be used to trigger a Fetch action instead of generate an email?

    All of in the Fetch community appreciate your efforts.
    Tim

    Posted 3 years ago #

  • Jim Matthews Administrator

    What action would you want Fetch to take when it spots a new file?

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 3 years ago #

  • Tim Hodge Member

    Ideally, I would like it to download the new file to my local drive into a folder with the same name as the remote. For example, if the new file was in a remote folder named "0423" I would like it to download into a local 0423 folder.

    Thanks!

    Posted 3 years ago #

  • Jim Matthews Administrator

    Hi,

    I could have it do that. Should it do anything with the files it sees when you first launch the script, or should it only download and notify you of files that appear after that?

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 3 years ago #

  • Tim Hodge Member

    There will be multiple files in the folders. All I would want is the newest file.
    Actually this script could be launched once weekly to get the newest file from all folders it sees.
    0213
    0234
    0308
    0423
    0423
    0423
    0423...etc

    I would like it to get the newest file from each folder, then place in locally in a folder with the corresponding name.

    Thanks!

    Posted 3 years ago #

  • Jim Matthews Administrator

    Hi,

    Are all the remote folders (0213, 0234, etc.) in the same parent folder?

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 3 years ago #

  • Tim Hodge Member

    Yes... FTP is into the "root."
    Subfolders are there...
    /0213
    /0234 etc

    On the local machine, the folders could be in a desktop folder (named "files" or whatever.
    Running this script once weekly would be sufficient for me.

    Thanks!

    Posted 3 years ago #

  • Jim Matthews Administrator

    Hi,

    I have something for you to test. Could you contact me at http://fetchsoftworks.com/fetch/feedback ?

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 3 years ago #

  • Tim Hodge Member

    I submitted the form Jim. I'm thinking it went through but if not, please let me know.
    Thanks a million.
    Tim

    Posted 3 years ago #

  • Jim Matthews Administrator

    Hi Tim,

    I missed your note initially, but now I've sent a reply with the script. Let me know what you think!

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 3 years ago #

  • Tim Hodge Member

    Hi Jim,
    Your script works very well. Thanks so much.
    The only issue that happens (about half the time) is the script bails with "AppleEvent timed out".
    I suspect it may be the GoDaddy servers stalling. Thoughts?
    I may be looking for a more robust server solution than the shared GoDaddy one.

    Early in this thread, you mentioned that you had a script that would watch server folders and send me an email? I would love to see this. Getting notice would allow me to preform so local processing manually. Eventually, I'll try to automate this too. Baby steps.

    Thanks for your help.
    I will fill out the feedback form if it's possible to send me the "folder watch" script.

    Posted 3 years ago #

  • Jim Matthews Administrator

    Please do send me another note using the feedback form. I have an idea of a fix for the timeout problem, and I'd be happy to change the script to send emails.

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 3 years ago #

  • Tim Hodge Member

    That seems to have done the trick!
    I've run it 3 times with no problems. It's grabbing the newest files from about 120 remote folders (900MB), downloading them and then emailing me a list when completed.

    I see you added a timeout of 3600 seconds.

    with timeout of 3600 seconds
    open url inSourceURL
    end timeout

    Thanks for your help. Much appreciated.

    Posted 3 years ago #

  • Jim Matthews Administrator

    Yes, I had forgotten to add the timeout lines earlier. So now it should work as long as it doesn't take more than an hour to list a folder or download a file.

    I'm glad to hear it's working now.

    Thanks,

    Jim Matthews
    Fetch Softworks

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