Build File Name Including the Current Date |
Top Previous Next |
The example script file shown below obtains the current date by parsing the %date internal variable. The digits of the date are reformatted and appended to a variable named filename containing the value "TestFile_" so that the variable's ultimate value is TestFile_mmddyyyy.txt where mm is the two digit month, dd is the two digit day, and yyyy is the four digit year.
SETLEFT month = date 2 SETMID day = date 2 4 SETRIGHT temp = date 2 SET year = "20" SET year &= temp SET filedate = month SET filedate &= day SET filedate &= year DISPLAY filedate SET filename = "TestFile_" SET filename &= filedate SET filename &= ".txt" DISPLAY filename
Multiple calls to the SETEXTRACT command can optionally be used instead of the combination of SETLEFT, SETMID and SETRIGHT.
Before parsing the date into a file name string you could use the DATEADD or DATESUB commands together with the %date variable to finds dates in the future or in the past.
You could use this type of logic to calculate the names of files to be uploaded or to be downloaded.
Related Commands: DATEADD, DATESUB, DATETIMEADD, DATETIMESUB See also: List of Sample Script Files, Script File Wizard, Script Programming, Script Commands |