The professional tool to automate FTP and secure FTP transfers. Automated FTP & Batch FTP |
Transfer new and modified files only. Optionally delete orphaned files.
Syntax: SYNC(local_dir, remote_dir, method,SUBDIRS,wildcard)
| UPLOAD | Synchronize remote_dir from local_dir. All files in local_dir that do not exist in remote_dir will be uploaded. If a file exists in both locations it will be uploaded whenever the local_dir file is newer. |
| DOWNLOAD | Synchronize local_dir from remote_dir. All files in remote_dir that do not exist in local_dir will be downloaded. If a file exists in both locations it will be downloaded whenever the remote_dir file is newer. |
| UPLOAD_DELETE | Synchronize remote_dir from local_dir. All files in local_dir that do not exist in remote_dir will be uploaded. If a file exists in both locations it will be uploaded whenever the local_dir file is newer. Additionally, all remote_dir files that do not exist in local_dir (orphaned files) will be deleted. |
| DOWNLOAD_DELETE | Synchronize local_dir from remote_dir. All files in remote_dir that do not exist in local_dir will be downloaded. If a file exists in both locations it will be downloaded whenever the remote_dir file is newer. Additionally, all local_dir files that do not exist in remote_dir (orphaned files) will be deleted. |
Remarks:
Command compatibility:
ScriptFTP 2.1 Build Feb 2th 2006: The optional parameter "wildcard" is added.
ScriptFTP 2.2 Build April 4th 2006: The meaning of the third parameter has been changed. The UPLOAD and DOWNLOAD parameters do no longer perform any file deletion, use UPLOAD_DELETE and DOWNLOAD_DELETE instead.
Return Value:
SYNC will return "OK" if all synchronization operations except from deleting orphaned files were successful.
If SYNC fails it will return an error code. You may retrieve the return value and execute various operations depending on this value. See Error Handling.
See also:
GETFILE
PUTFILE
SETCLOCKDIFF
Examples:
# Connect to FTP server
OPENHOST("ftp.myhost.com","myuser","mypassword")
# Synchronize a local directory from an FTP site
SYNC("C:\accounting","/accounting",DOWNLOAD,SUBDIRS)
# Close connection
CLOSEHOST
# Connect to FTP server using FTP over SSL (secure)
SETPROTOCOL(FTPS_EXPLICIT)
OPENHOST("ftp.myhost.com","myuser","mypassword")
# Synchronize a web site from a local directory
SYNC("C:\local_website","/www",UPLOAD_DELETE)
# Close connection
CLOSEHOST
# Connect to server
OPENHOST("ftp.myhost.com","myuser","mypassword")
# Synchronize a single file only
SYNC("C:\accounting","/accounting",DOWNLOAD,"accounts.xls")
# Close connection
CLOSEHOST
# Connect to server
OPENHOST("ftp.myhost.com","myuser","mypassword")
# Synchronize all Excel files from an FTP site
SYNC("C:\accounting","/accounting",DOWNLOAD,SUBDIRS,"*.xls")
# You may also omit the SUBDIRS parameter:
# SYNC("C:\accounting","/accounting",DOWNLOAD,"*.xls")
# Disconnect
CLOSEHOST