Your best friend for file transfer.

Fetch application logoFetch

Applescript remote file search problem (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 13 years ago by gschoenthal
  • Latest reply 13 years ago from gschoenthal
  • gschoenthal Member

    When I try to execute the following script I get an error message in AppleScript that says "Fetch 4.0b6 got an error: Wrong keyword for a special function." It is giving this error because of my statement on the fourth line below, but I don't know what to change.

    tell application "Fetch 4.0b6"
    activate
    open remote directory "ftp://gss2r:......@blue.unix.virginia.edu/"
    set files_to_download to every remote file of the front window whose name contains ".tif"
    download remote file files_to_download
    end tell

    Posted 13 years ago #

  • Jim Matthews Administrator

    Unfortunately Fetch does not support the "whose" construct in AppleScript. You have to do something like:

    set files_in_dir to every remote file of transfer window 1
    repeat with afile in files_in_dir
    if name of afile contains ".tif" then
    download afile
    end if
    end repeat

    I'm not sure about the "contains" syntax, but the idea is that you do the test yourself.

    Jim Matthews
    Fetch Softworks

    Posted 13 years ago #

  • gschoenthal Member

    Jim,
    Here is how I finally fixed it

    tell application "Finder"
    set open_windows to every window
    if open_windows is not equal to {} then
    close open_windows
    end if
    end tell
    tell application "Fetch 4.0b6"
    activate
    open remote directory "ftp://gss2r:..@blue.unix.virginia.edu/eehome"
    set files_in_dir_eeultra to the name of every remote file of transfer window 1
    repeat with afile_eeultra in files_in_dir_eeultra
    if afile_eeultra contains ".jpg" then
    download remote file named afile_eeultra
    delete remote file named afile_eeultra
    else
    if afile_eeultra contains ".tif" then
    download remote file named afile_eeultra
    delete remote file named afile_eeultra
    end if
    end if
    end repeat
    close transfer window 1
    open remote directory "ftp://gss2r:..@blue.unix.virginia.edu/"
    set files_in_dir_blue to the name of every remote file of transfer window 1
    repeat with afile_blue in files_in_dir_blue
    if afile_blue contains ".jpg" then
    download remote file named afile_blue
    delete remote file named afile_blue
    else
    if afile_blue contains ".tif" then
    download remote file named afile_blue
    delete remote file named afile_blue
    end if
    end if
    end repeat
    close transfer window 1
    quit
    end tell
    tell application "Finder"
    if open_windows is not equal to {} then
    open open_windows
    end if
    end tell

    Posted 13 years ago #

Topic closed

This topic has been closed.