Since SYNC() doesn't preserve the local timestamp on the uploaded file, I decided to try to write a script to do so. Here's one I'm testing...
And here's the output results...
I have no idea why the SETFILETIME() doesn't work.
Code: Select all
# Connect to FTP server
OPENHOST("ftp.*****.***","******@*****.***","*****")
$file_name="TestFile.zip"
$remote_dir=""
$remote_file_size=0
$remote_file_time=""
$local_dir="E:\Users\Paul\Test\ZipBackup"
$local_file_size=0
$local_file_time=""
$remote_file_size=GETFILESIZE(REMOTE,$remote_dir.$file_name)
$remote_file_time=GETFILETIME(REMOTE,$remote_dir.$file_name)
$local_file_size=GETFILESIZE(LOCAL,$local_dir."\".$file_name)
$local_file_time=GETFILETIME(LOCAL,$local_dir."\".$file_name)
PRINT("")
PRINT("------------------------------------")
PRINT("File: " . $file_name)
PRINT("")
PRINT("Remote directory: " . $remote_dir)
PRINT("FILE TIME: " . $remote_file_time)
PRINT("FILE SIZE: " . $remote_file_size)
PRINT("")
PRINT("Local directory: " .$local_dir)
PRINT("FILE TIME: " . $local_file_time)
PRINT("FILE SIZE: " . $local_file_size)
PRINT("------------------------------------")
PRINT("")
IF(($local_file_time > $remote_file_time))
PRINT("UPLOAD this file.")
PUTFILE($local_dir."\".$file_name)
SETFILETIME(REMOTE,$remote_dir.$file_name,$local_file_time)
ELSE
PRINT("Do NOT UPLOAD this file.")
END IF
# Transfer finished, close the connection
CLOSEHOST
And here's the output results...
Running E:\Users\Paul\Test\ZipBackup\test_sync.ftp
OPENHOST("ftp.*****.***","******@*****.***","*****")
Connecting to ftp.*****.***
Connected.
GETFILESIZE(REMOTE,"TestFile.zip")
GETFILETIME(REMOTE,"TestFile.zip")
GETFILESIZE(LOCAL,"E:\Users\Paul\Test\ZipBackup\TestFile.zip")
GETFILETIME(LOCAL,"E:\Users\Paul\Test\ZipBackup\TestFile.zip")
------------------------------------
File: TestFile.zip
Remote directory:
FILE TIME: 2000_01_01-06_00_00
FILE SIZE: 21416
Local directory: E:\Users\Paul\Test\ZipBackup
FILE TIME: 2009_01_20-21_50_58
FILE SIZE: 21416
------------------------------------
UPLOAD this file.
PUTFILE("E:\Users\Paul\Test\ZipBackup\TestFile.zip")
Uploading................. TestFile.zip
SETFILETIME(REMOTE,"TestFile.zip","2009_01_20-21_50_58")
Setting remote file TestFile.zip modification time to 20/01/2009 - 21:50:58.
***** SETFILETIME Error #17550: Cannot change modified time of the remote file TestFile.zip.
***** The server said: Can't check for file existence
CLOSEHOST
Disconnected.
I have no idea why the SETFILETIME() doesn't work.
Hi Paul,
Setting remote file TestFile.zip modification time to 20/01/2009 - 21:50:58.
***** SETFILETIME Error #17550: Cannot change modified time of the remote file TestFile.zip.
***** The server said: Can't check for file existence
I have no idea why the SETFILETIME() doesn't work.Neither me. According to the error message the server had some trouble. Could you enable VERBOSE(ON) and repost the script output?
liked Script FTP? Try our other product Email Parser