ftp automation

ScriptFTP

The professional tool to automate FTP, SFTP, FTPS and schedule FTP batch jobs

The forum is now read only. Please, go to the the main ScriptFTP website if you need help.
Need help writing a script? Have any question about ScriptFTP?
I would like to try out and possibly buy scriptftp if it works to my needs.

What I need is a script that...

1. Connects to my FTP server using Explicit SSL (Auth SSL) port 990
2. Downloads all files in the root dir.
3. Scan folders recursively and download files within.
4. After Successful download of the files, delete the files and folders from server.
Hi Rick,

Try this one:

[scriptftp="download_and_delete.ftp"]# Connect to the FTP server:
SETPROTOCOL(FTPS_EXPLICIT_ENCRYPT_DATA)
SETPORT(990)
OPENHOST("ftp.example.com","myuser","mypassword")

# Current local directory will be:
LOCALCHDIR("c:\my_destination_folder")

# Download every file and directory
$result=GETFILE("*.*",SUBDIRS)

# If everything has been successfully downloaded, remove the remote files and directories
IF($result=="OK")
# Use with caution. It will remove any file or folder in the remote site
RMDIR("/")
END IF

# Close the connection
CLOSEHOST[/ScriptFTP]

The drawbacks of this script is that if someone uploads a new file to the site just after we download a directory it will get deleted in the RMDIR() step but will not be downloaded.

To prevent this there are more complex solutions using FOREACH and GETLIST and downloading and deleting file by file and directory by directory. If you think that the problem that I described before may happen in your case please post here and I will write a new example with this other approach.