Your best friend for file transfer.

Fetch application logoFetch

Applescript II (5 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 21 years ago by rosmifetch
  • Latest reply 21 years ago from Jim Matthews
  • rosmifetch Member

    Hi Jim-
    I need to make changes to the following applescript handler (i've removed some non essential stuff for this post)

    on fetchcopy(filestoprocess)
    set curdfurl to item 2 of filestoprocess
    set myfile to item 1 of filestoprocess
    tell application "Fetch 4.0.2"
    activate
    put into url curdfurl item myfile binary format Raw Data text format Raw Data
    close transfer window 1
    end fetchcopy

    I'm having problems overwriting existing files before I upload a replacement file to an aix4.3 server.
    As a fix, I need to to try and delete the file at the url before I copy up it's replacement.
    I know I can do a delete with "delete remote file 'filename'" but is there a way to delete given an url and filename?

    Posted 21 years ago #

  • Jim Matthews Administrator

    You could do something like:

    set fullurl to curdfurl & (name of myfile)
    delete url fullurl

    If curdfurl does not end in a slash you might need to say this instead:

    set fullurl to curdfurl & "/" & (name of myfile)
    delete url fullurl

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 21 years ago #

  • rosmifetch Member

    I had change
    "set fullurl to curdfurl & "/" & (name of myfile)"

    to

    Tell Application "Finder" to set fullurl to curdfurl & "/" & (name of myfile)

    ... but it worked!
    Thanks!

    Posted 21 years ago #

  • rosmifetch Member

    How do I get Fetch 4.x to return a list of files from a remote server into a variable that's a list

    something like

    Tell Application "Fetch 4.0.2"
    set myfilelist to (results of "ls -al") as list
    end tell

    I did it in fetch 3.x but now it doesn't work :BR>here's what I used to use with fetch 3.x
    --------------------
    set dirignore to {".", "..", ".rsrc"}
    tell application "Fetch 4.0.2"
    activate
    open url myurl
    set mywind to a reference to transfer window 1
    set fetchcount to count mywind each remote item
    end tell
    if fetchcount > 2 then
    -- at the time I didn't know how to ignore the dotted files repeat with itemcounter from 2 to fetchcount
    tell application "Fetch 4.0.2" to set myname to (name of (a reference to remote item itemcounter of mywind))
    if not (myname is in dirignore) then
    if myname = {} then
    set mydir to {myname}
    else
    set end of mydir to myname as list
    end if
    end if
    end repeat
    tell application "Fetch 4.0.2" to close mywind
    end if

    Posted 21 years ago #

  • Jim Matthews Administrator

    To get the names of the items in the Fetch file list into an AppleScript list you'd say:

    set itemlist to name of every remote item

    If you wanted only file names you'd say "every remote file", for directory names you'd say "every remote directory".

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 21 years ago #

Topic closed

This topic has been closed.