Build File Name Including the Current Date

Top  Previous  Next

 

The example script file shown below obtains the current date and appends it to a file named TestFile. The variable file name is set to TestFile_mmddyyyy.txt where mm is the two digit month, dd is the two digit day, and yyyy is the four digit year.

 

SET date = %date

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