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?
All - I am new to ScriptFTP and if I missed the answer to my question when I searched the forums I apologize in advance.

I am working on a script that needs to create a folder on a network share based on a past date. In addition I am needing to download files from the remote sFTP server that use this same past date. I am able to get my script to work using the (FORMAT0) format but am trying to get the defined variable into the (FORMAT3) so that I have YYYYMMDD layout.

The remote files are loaded to the FTP server weekly on a Wednesday with a file date from 2 Friday's prior (so if the file is loaded tomorrow on FTP, the date in the file would be 7/28)

I have defined variables that can get me the correct date using the (FORMAT0) layout:
FTP Script
  1. $date=GETTIME(FORMAT0)
  2. $filedate=$date-(12*24*60*60)
This works fine. And then I can create a new directory:
FTP Script
  1. # creates the directory like so:  2017_7_27-12_10_43
  2. LOCALMKDIR($filedate)
My desired directory name is 20170727

I have tried different syntax methods to get the format for the variable $filedate to use (FORMAT3) but all fail. I also need this same format to use in the GETFILE command to grab the correct file from the remote FTP server....

Any assistance is appreciated!
Thanks for posting here. Don't worry a question like this has never been answered in the forum ;)
LOCALMKDIR($filedate) - which creates the directory like so: 2017_7_27-12_10_43

I would update ScriptFTP to the latest version. In the recent releases the date/time format always uses two digits for months, days etc. For example the date/time you used would be:

2017_07_27-12_10_43

This makes much easier to extract the day and the month with TEXTCUT as they always have the same position in the text string:
FTP Script
  1. $date=GETTIME(FORMAT0)
  2. $filedate=$date-(12*24*60*60)
  3.  
  4. $year = TEXTCUT($filedate,1,4)
  5. $month= TEXTCUT($filedate,6,2)
  6. $day= TEXTCUT($filedate,9,2)
  7.  
  8. $directory_name = $year.$month.$day
  9. PRINT($directory_name)
The output of the script is:
GETTIME("FORMAT0")
TEXTCUT("2017_07_29-18_46_45","1","4")
TEXTCUT("2017_07_29-18_46_45","6","2")
TEXTCUT("2017_07_29-18_46_45","9","2")
20170729
Just updated to 4.3 and this works perfect now. Thank you so much!!