PDA

View Full Version : Tip: How to name a file based on today's DATE and TIME



CARDAN
08-31-2009, 01:24 PM
As part of my SB7 Installation, I had to backup an existing TPS file in the Target folder to a file name that included the DATE and TIME.

Example:
Original file name: proold.tps
Copied file name: proold_20090825-1708.tps (yyyymmdd-hhmm).

Very simple to accomplish: All done from within SB7 Script Editor:

1. I positioned the cursor in the #include script "Common Definitions.sbi" section; then I double-clicked on the "Set Variable" Function under Script Functions, General Installer Functions. Within that dialog I created my own Variable to hold today's DATE: %DC_CURRDATE%

2. Repeat for today's TIME: %DC_CURRTIME%

3. After the "Install Files" section I added the Get System Info function to retrieve the Current Date and I stored it into my %DC_CURRDATE% Variable using Date Format 11 because Windows can't handle dashes/colons: in the date or time.

4. Repeat for today's TIME: %DC_CURRTIME%, format 2 (See page 354 of SB7 PDF Manual for all available Date and Time "pictures").

5. Finally, I used the Copy Files function to end up with the final file that included today's DATE and TIME as part of the file name:
Source: [INSTALLDIR]\proold.tps
Target: [INSTALLDIR]\proold_bak_%DC_CURRDATE%-%DC_CURRTIME%.tps

That it!

I learn a lot on how powerful the build-in functions are to accomplish just about any task you want. Also, the PDF Manual was VERY helpful.

SB7: Great product and very flexible...

Thanks.

Daniel Carrasco

linder
09-01-2009, 04:15 AM
Daniel,

Thanks so much for your kind words and for sharing this very interesting information!

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder is installation -- "point. click. ship"

-- Official Comodo Code Signing and SSL Certificate Partner