Your best friend for file transfer.

Fetch application logoFetch

Applescript question 2 (2 posts)

  • Started 10 years ago by Nico
  • Latest reply 10 years ago from Jim Matthews
  • Nico Member

    Hello Jim and others,

    Can you please explain what is the best way to retrieve transfer window properties back into Applescript?
    My objective is to write information about a file transfer (like tranfser rate, bytes transferred) to a logfile maintained by the Applescript.

    I did some experiments and found that my example sometimes (about 1 out of 20) reports the transfer rate correctly, but all other times the returned transfer rate is 0.

    Here is some (stripped down) code I experimented on. Can you please advise how to improve?

    ----
    on open doc
    set fetchconnection1 to fetchconnect(theServerAddress, thePort, theUserName, thePassword, theDirectory)
    repeat with oneDoc in doc
    tell application "Finder"
    set oneDocName to name of item (contents of oneDoc)
    end tell
    with timeout of 60000 seconds
    try
    tell application "Fetch"
    try
    put into transfer window 1 item oneDoc with uniquename
    on error
    --blah
    end try
    set fetch_transferrate1 to fetch_transferrate() --> this is where I try to get the transfer rate from Fetch Transfer Window 1
    display dialog fetch_transferrate1
    end timeout
    end repeat
    end open

    --Subroutines--
    on fetch_transferrate()
    tell application "Fetch"
    tell transfer window 1
    transfer rate
    end tell
    end tell
    end fetch_transferrate

    on fetchconnect(theServerAddress, thePort, theUserName, thePassword, theDirectory)
    with timeout of 20 seconds
    try
    tell application "Fetch"
    make new transfer window at beginning with properties {hostname:theServerAddress, port:thePort, username:theUserName, password:thePassword, initial folder:theDirectory, authentication:SFTP, encrypt:true}

    end tell
    on error the_errormessage
    --blah
    end try
    end timeout
    end fetchconnect

    Posted 10 years ago #

  • Jim Matthews Administrator

    If a transfer takes less than a second Fetch will report a transfer rate of zero. You might want to calculate the transfer rate yourself:

    set startTime to the current date
    set endTime to the current date
    set transferTime to endTime - startTime

    Thanks,

    Jim Matthews
    Fetch Softworks

    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.