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?
Hello,

I just downloaded your program and am trying to use the SYNC command to update files ONLY if they are newer on the Remote Side and NOT the local side.

The example below works exactly as I want but it only sync's if the Local side has newer files:
Code: Select allSYNC("c:\domain\domain_backup","domain.net",UPLOAD_DELETE, SUBDIRS)
Basically, I want to SYNC only if the Remote Side has changed the content.

Is this something that is possible with ScriptFTP?

Thanks for your help,

--Duane
Hi,

As the SYNC criteria is the opposite, I think that the only solution is to compare local and remote file sizes with GETFILESIZE. If they are different, upload the file. The problem with this solution is that you cannot go through subdirectories. It would be something like this:
Code: Select allGETLIST($fileList,REMOTE_FILES) FOREACH $fileName IN $fileList $remoteFileSize = GETFILESIZE(REMOTE, $fileName) $localFileSize = GETFILESIZE(LOCAL, $fileName) IF($remoteFileSize != $localFileSize) PUTFILE($fileName) END IF END FOREACH
If you need a more detailed example or any further questions feel free to post here again.
Hello,

If I may say, the script would be better if a double check were made on the files, like as follows:
Code: Select allGETLIST($fileList,REMOTE_FILES) FOREACH $fileName IN $fileList $remoteFileSize = GETFILESIZE(REMOTE, $fileName) $remoteFileTimeStamp = GETFILETIME(REMOTE, $fileName) $localFileSize = GETFILESIZE(LOCAL, $fileName) $localFileTimeStamp = GETFILETIME(LOCAL, $fileName) IF($remoteFileSize != $localFileSize AND $remoteFileTimeStamp != $localFileTimeStamp) PUTFILE($fileName) END IF END FOREACH
This would make sure that files that have changed content but not size have been synchronised.

HTH

Zythan
Thanks Duane, you are right. But note that if the computer where ScriptFTP is running and the FTP server have different local times the file date will be always different.
Hello,

The SETCLOCKDIFF command would then be of use, I presume.

Regards.

Zythan
MMmmm not, the clock time difference set with SETCLOCKDIFF is only applied when synchronizing files. If you request a file modification time to the FTP server with GETFILETIME the returned time is the one reported by the FTP server, the time difference is not applied.

I think I should consider changing this behavior.