FTP Script to download a set of files

ftpscripting

I am after an FTP script to download all the files from an FTP server, then delete these files once complete, but leave files on the remote server if any were added during the download process, to be fetched during a later session.

Is it possible to achieve something like this using FTP scripts or do I need a different solution.

I was planning on using psftp.

Best Answer

Based on Maxwell's answer to this question, I would probably do something along the lines of this pseudocode:

Use $favorite_scripting_language to gather the list of filenames to d/l then kill; write an output file named script.txt in the form:

cd /source/directory
lcd c:\target\directory
get foo.bar
delete foo.bar
<<lather, rinse, repeat>>

then wrap it up with:

psftp.exe username@server -be -pw user_password -b c:\script.txt