Download, Save, Delete Old, and Re-upload newly downloaded File


I am looking for a script that seems simple (in concept), but I have no idea of how to make it. Below, I have outlined what actions (and in what order) I want this application to do/work:

  1. On a given date (or after a certain amount of time has elapsed - to be added later)
  2. Download a specific file from a provided website URL;
  3. Save that file into a specific folder on the desktop;
  4. Then go to a specific FTP location;
  5. Delete the file that’s in the FTP folder (the file we just downloaded is going to replace the current file in the FTP folder) right now;
  6. Re-upload the current file that we just downloaded to replace the file we deleted.
  7. Save the FTP/Update/Upload the FTP files to the server.

… And I need to be able to do this for a LOT of domains.

Basically, we are (on a specific date/after a certain amount of time has lapsed since the last download) downloading an updated file from a given URL. We are then saving it in a specific folder on my computer. After we have the new file, we are going into the FTP directory for my website and pulling out the outdated version of this file. Then, we are taking the new file, putting it in the place of the file we just deleted from the FTP, and uploading the FTP to the server to replace the file.

Thanks for the help.

Best Regards,


the best way to manage FTP access to a server with AppleScript is cURL.
When a file is uploaded with the same URL (including the file name) as an existing file, the file will be overwritten

This might be a starting point

-- FTP access data
property FTPServerFolderURL : "ftp.MyServer/path/to/folder/" -- the trailing slash is mandatory
property user : "username"
property pass : "p¢¢¢w¢rd"

-- the name of the file
set fileName to "text.txt"
-- the location on the computer
set desktopFolder to POSIX path of (path to desktop)

-- the full URL on the server
set serverURL to FTPServerFolderURL & fileName
-- the full path on desktop
set filePath to desktopFolder & fileName

-- call handler to download file
curlDownload(serverURL, filePath)

-- call handler to upload file
curlUpload(filePath, serverURL)

-- handlers
on curlDownload(sourceURL, destinationPath)
	do shell script "curl -o " & quoted form of destinationPath & " -u " & user & ":" & pass & space & quoted form of sourceURL
end curlDownload

on curlUpload(sourcePath, destinationURL)
	do shell script "curl " & quoted form of destinationURL & " -u " & user & ":" & pass & " -T " & quoted form of sourcePath
end curlUpload

HI StefanK,

Thanks for the reply. Looks like I will be downloading/uploading (let’s say “dealing with” for simplicity) 15,000+ files. All with different file names. Would it be possible to fill out this applet to handle that level of load? Is that too much for AppleScript to handle?


Best Regards,

Of course it’s possible. You have to add repeat loops depending on your data structure. cURL works synchronously that means the AppleScript line after the cURL line will be executed after finishing the transfer

Sorry for the delay in response. I am working closer with this script, and it seems to be doing very well! Thank you for your help!!