Archives
- July 2019
- January 2019
- November 2018
- August 2018
- July 2018
- February 2018
- November 2017
- October 2017
- July 2017
- June 2017
- May 2017
- April 2017
- January 2017
- December 2016
- November 2016
- August 2016
- January 2015
- December 2014
- March 2014
- April 2013
- December 2010
- November 2009
- September 2009
- June 2009
- March 2009
- February 2009
- November 2008
- October 2008
- August 2008
- July 2008
- January 2008
Uploading only the files created or modified in the last 7 days
29th January 2019
The following script shows how to upload to the FTP server the files from the last 7 days. If a file is more than 7 days old it will be ignored.
Note that this example does not work with subfolders.
# Connect to the FTP site OPENHOST("ftp.myserver.com","johndoe","1234") # What time is it? $today = GETTIME() # ScriptFTP handles time spans in seconds. See: # https://www.scriptftp.com/b/handling-file-dates-and-time-spans $seven_days_in_seconds = 7 * 24 * 60 * 60 PRINT("Today is: ".$today) PRINT("Seven days in seconds is: ".$seven_days_in_seconds) # We are uploading the files from local_folder to remote_folder $local_folder = "C:\Users\JohnDoe\Desktop\The Files" $remote_folder = "/my_folder" # Change the current local folder LOCALCHDIR($local_folder) # Change the current remote filder CHDIR($remote_folder) # Get the listing of the local folder GETLIST($local_file_list,LOCAL_FILES) # For each file in the local folder FOREACH $file IN $local_file_list # what is the date of this file? $file_time=GETFILETIME(LOCAL,$file) # We only upload the file if it is not older # than a week. IF(($today - $file_time) < $seven_days_in_seconds) PUTFILE($file) ELSE PRINT("The file is older than a week. Skipping this file") END IF END FOREACH # Say goodbye to the FTP server and close the connection CLOSEHOST