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 share here a question I received via email. The customer was asking about how to calculate the yesterday's date.

He (or she) wanted to download only a specific xls file from a FTP site which name is the yesterday's date. For example: "12-4-2013.xls". The example we gave was the following:

[scriptftp="yesterday.ftp"]# Connect to FTP server
OPENHOST("ftp.myhost.com","myuser","mypassword")

# The current date and time is
$current_date_and_time = GETTIME()

# This should show something like "2013_04_11-12_18_07" in the ScriptFTP window
PRINT($current_date_and_time)

# Substract 24 hours (86400 seconds) from the current date
# See http://www.scriptftp.com/reference.php?go=topic560 (scroll to "operations with dates")
$current_date_and_time_minus_24h = $current_date_and_time - 86400

# This should show something like "2013_04_10-12_18_07" in the ScriptFTP window
PRINT($current_date_and_time_minus_24h)

# The filename will be the first 10 characters and then the ".xls"
$filename = TEXTCUT($current_date_and_time_minus_24h,1,10) . ".xls"

# Download the xls file
GETFILE($filename)

# Close the connection
CLOSEHOST()[/ScriptFTP]