Automator + Applescript > copy files from folder

Discussion in 'Mac Programming' started by belgrowa, May 31, 2017.

  1. belgrowa macrumors newbie

    Joined:
    May 30, 2017
    #1
    I want to make backup of remote ftp folder to local folder. In Automator, I had an applescript that mount my remote ftp:

    on run {input, parameters}
    #Connect to server
    tell application "Finder"
    mount volume "ftp://server_name/path_to_folder/img" as user name "user_name" with password "password"
    end tell
    return input
    end run

    It Is working - my remote ftp is mounted.

    What next step to use to copy the contents of the "img" folder to my local folder? Automator "Copy Finder items" not work. I get error "Copy the Finder stuff was not delivered with the required data".

    Please help.
     
  2. kryten2, May 31, 2017
    Last edited: May 31, 2017

    kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    Why not use a dedicated ftp program to do this? I gave up on Automator as I don't have time to test things. Here's an AppleScript example :

    Code:
    -- Connect to server, Mount the volume
    set fileSpecifierForMountedVolume to (mount volume "ftp://192.168.204.1/Afbeeldingen/Webcam" as user name "******" with password "*******") --as alias
    
    -- Get users pictures folder path as an example
    set picturesFolderPath to path to pictures folder
    
    -- Duplicate the stuff using the Finder
    tell application "Finder"
        -- Duplicate every file of folder fileSpecifierForMountedVolume to folder picturesFolderPath
        duplicate files of folder fileSpecifierForMountedVolume to picturesFolderPath
        -- Duplicate folder Webcam to folder picturesFolderPath
        duplicate fileSpecifierForMountedVolume to picturesFolderPath
    end tell
    Note : The Copy Finder Items needs files/folders as input. I'm also guessing that the Run Applescript action is the first one and it receives no input yet you return input in the handler.
     
  3. belgrowa thread starter macrumors newbie

    Joined:
    May 30, 2017
    #3
    Kryten2 Thanks! But in my case, this work:

    -- Connect to server, Mount the volume
    set fileSpecifierForMountedVolume to (mount volume "
    mount volume "ftp://192.168.204.1/Afbeeldingen/Webcam" as user name "******" with password "*******"
    ) --as alias

    -- Get users pictures folder path as an example
    set picturesFolderPath to "/Users/name/Desktop/backup" as POSIX file

    -- Duplicate the stuff using the Finder
    tell application "Finder"

    -- Duplicate every file of folder fileSpecifierForMountedVolume to folder picturesFolderPath
    #duplicate files of folder fileSpecifierForMountedVolume to picturesFolderPath
    -- Duplicate folder Webcam to folder picturesFolderPath
    duplicate fileSpecifierForMountedVolume to picturesFolderPath with replacing

    end tell

    But there is problem - it is very slow :( I have got an error: Finder got an error: AppleEvent timeout.

    Why? Can I fix it?
     
  4. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #4
  5. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #5

Share This Page