Mark Mark - 1 month ago 6x
Bash Question

Copy all files from one FTP directory to another

I have to copy all existing files inside one ftp directory to another ftp directory on another server. I have not had any experience writing scripts - so any help with this would be great.

I'm wondering if its possible to write this script so that it happens every day at a specific time?

What software/ language should I use for this? Python is a well renowned one, but I want to make sure it suits my requirements.

Can someone give me a basic code implementation for how to do it?

Thanks in advance


In the end you will probably end up downloading the whole directory to a local machine and re-uploading it to the other, as there's generally no way to copy files between directories in FTP.
See FTP copy a file to another place in same FTP.

You will find plenty of examples for downloading and uploading. You do not even need a scripting language. Simply use some command-line FTP client.

For example with WinSCP FTP client, you can use the following batch file (.bat): /log=copy.log /command ^
    "open" ^
    "get /source/remote/path/* C:\temporary\local\path\" ^
    "put C:\temporary\local\path\* /destination/remote/path/" ^

See the guide to Automating file transfers to and from FTP server.

(I'm the author of WinSCP)