Your best friend for file transfer.

Fetch application logoFetch

copy or move files between directories (3 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 19 years ago by guest
  • Latest reply 18 years ago from guest
  • guest Registered Member

    Hi

    I managed to copy files to an ftp site using applescript. Now I would like to set up a folder, or is it directory, for incoming files and move them to another directory in the evening so my first directory only gets new files each day. Here's what I tried, can you tell me where I went wrong?
    tell application "Fetch 4.0.3"

    make new transfer window at beginning with properties {hostname:"xxxxx", userid:"xxx", password:"xxxxx"}
    open remote directory "ebks_storage"

    make new transfer window at beginning with properties {hostname:"xxxxx", userid:"xxx", password:"xxxx"}
    open remote directory "DF" --for transfer List
    set itemcount to count of transfer window 1 each remote item

    set itemName to the name of remote item 1 of transfer window 1
    copy remote item itemName to remote directory "ebks_storage"

    end tell

    Posted 19 years ago #

  • Jim Matthews Administrator

    I would try something like this:

    make new transfer window at beginning with properties {hostname:"xxxxx", userid:"xxx", password:"xxxx"}
    open remote directory "DF" --for transfer List
    set itemcount to count of transfer window 1 each remote item
    if itemcount > 0 then
    set allnames to name of every remote file of transfer window 1
    repeat with onename in allnames
    set name of remote file (onename as string) to ("../"ebks_storage"/" & onename)
    end repeat
    end if

    Let me know if that does not work for you.

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 19 years ago #

  • guest Registered Member

    I think you had a slight syntax error in yours. I tried 2 variations. First, I tried this using "items" in place of "files". This was to also transfer directories. Sometimes it worked, but other times the files would vanish from the first folder (directory) but I don't know where they went!

    make new transfer window at beginning with properties {hostname:"xxxxxxx", userid:"xxxxxxxxxxx", password:"xxxxxx"}
    open remote directory "DF" --for transfer List
    set itemcount to count of transfer window 1 each remote item
    if itemcount > 0 then
    set allnames to name of every remote item of transfer window 1
    repeat with onename in allnames
    set name of remote item (onename as string) to ("/ebks_storage/" & onename)
    end repeat
    end if
    end tell

    So to try and make the program more precise, I separated the file and diretory routines. So far, this one seems to work.

    make new transfer window at beginning with properties {hostname:"xxxxxxx", userid:"xxxxxxxxxxx", password:"xxxxxx"}
    open remote directory "DF" --for transfer List
    set itemcount to count of transfer window 1 each remote file
    set foldercount to count of transfer window 1 each remote directory
    if itemcount > 0 then
    set allnames to name of every remote file of transfer window 1
    repeat with onename in allnames
    set name of remote file (onename as string) to ("/ebks_storage/" & onename)
    end repeat

    end if
    if foldercount > 0 then
    set allFolders to the name of every remote directory of transfer window 1
    repeat with oneFolder in allFolders
    set name of remote directory (oneFolder as string) to ("/ebks_storage/" & oneFolder)
    end repeat
    end if
    end tell

    Posted 18 years ago #

Topic closed

This topic has been closed.