Mac Automator + Applescript > copy files from folder

belgrowa

macrumors newbie
Original poster
May 30, 2017
2
0
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.
 

kryten2

macrumors 6502a
Mar 17, 2012
999
60
Belgium
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.
 
Last edited:

belgrowa

macrumors newbie
Original poster
May 30, 2017
2
0
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?
 

kryten2

macrumors 6502a
Mar 17, 2012
999
60
Belgium
  • Like
Reactions: superscape
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.