Your best friend for file transfer.

Fetch application logoFetch

Appescript/ Synchronize folders (6 posts)

This is an archived topic. The information in it is likely to be out-of-date and no longer applicable to current versions of Fetch.
  • Started 22 years ago by btaylor
  • Latest reply 22 years ago from Jim Matthews
  • btaylor Member

    Hi

    I'm trying to get a folder on a local mac to update a folder on an ftp server by uploading newer files only. I am adapting the ynchronise folders Applescript and am having trouble guessing the syntax that fetch uses to get a remote file listing and maybe later will have trouble figuring out how to get the modification date of a file on the server. Here is what I have so far

    set baserfolder to "ftp://abcd:xyz@ftp.pqr/ftpfolder"
    set baseLfolder to "PBHD:PDF:"

    tell application "Finder"
    open file "Fetch 4.0" of folder "Fetch 4.0 Folder" of startup disk
    end tell
    tell application "Fetch 4.0"
    activate
    open remote directory baserfolder
    set upload format of transfer window 1 to Raw Data
    SyncFolders(baseLfolder, baserfolder) of me

    end tell

    on SyncFolders(Lfolder, rfolder)
    tell application "Finder"
    set LocalContents to list folder Lfolder
    end tell
    tell application "Fetch 4.0"
    -- can't get the suyntax right for the next line
    set RemoteContents to list url rfolder
    end tell
    repeat with x in LocalContents
    if x is not in RemoteContents then
    tell application "Fetch 4.0"
    put into rfolder item alias x
    end tell
    --duplicate alias ((folder1 as text) & x) to folder folder2
    else
    if kind of alias ((Lfolder as text) & x) is "folder" then
    SyncFolders(((Lfolder as text) & x) as alias, ((rfolder as text) & x) as alias) of me
    else
    tell Finder
    set date1 to modification date of alias ((Lfolder as text) & x)
    end tell
    tell application "Fetch 4.0"
    set date2 to modification date of remote file ((rfolder as text) & x)
    end tell
    if date1 > date2 then
    tell application "Fetch 4.0"
    put into rfolder item alias x
    end tell
    end if
    end if
    end if
    end repeat

    end SyncFolders

    Posted 22 years ago #

  • Jim Matthews Administrator

    I think that instead of:

    set RemoteContents to list url rfolder

    you want:

    open url rfolder
    set RemoteContents to name of every remote item of transfer window 1

    Jim Matthews
    Fetch Softworks

    Posted 22 years ago #

  • btaylor Member

    Thanks for you reply Jim,
    I tried the code
    set RemoteContents to the name of every remote item of transfer window 1

    and

    set RemoteContents to the name of every remote file of transfer window 1

    and

    set RemoteContents to the name of e remote item 1 of transfer window 1

    but consistently get a message
    "Can't make some data into the expected type"

    cheers Bill

    Posted 22 years ago #

  • Jim Matthews Administrator

    That appears to be a bug; it should be fixed in the next release.

    In the meantime have you tried using the mirror Apple Event?

    Jim Matthews
    Fetch Softworks

    Posted 22 years ago #

  • btaylor Member

    Hi Jim,

    The mirror event seems to be the way to go but again I can't seem to get thesyntax correct.

    Perhaps you would be kind enough to post an example based on the following

    mirror "HD:PDF:" to remote directory "PDF/" of transfer window 1 with format Raw Data and delete strays

    cheers Bill

    Posted 22 years ago #

  • Jim Matthews Administrator

    I think you want:

    mirror alias "HD:PDF:" to remote directory "ftp://userid :password@hostname/path/" with format Raw Data and delete strays

    Another way to get the right syntax is to perform the operation manually with the Record button pushed in the Script Editor.

    Jim Matthews
    Fetch Softworks

    [This message has been edited by JimMatthews (edited 07-27-2001).]

    Posted 22 years ago #

Topic closed

This topic has been closed.