- NSIS Discussion
- Howto add Timestamp to outfile?
Archive: Howto add Timestamp to outfile?
helios73
19th October 2006 10:13 UTC
Howto add Timestamp to outfile?
Hello,
I want to generate the outfile more dynamically by adding a timestamp like MMDDYY_HHMM.
Searching the doc I found __DATE__, __TIME__ and __TIMESTAMP__. __DATE__ works but if I add the __TIME__ information the filename is not writeable because of the ':' char.
Can someone give me some code for this task?
Regards,
Michael
kichik
20th October 2006 10:32 UTC
You can create a program that'd create a file with a date in it. Execute this program using !system and then !include the file it creates.
helios73
20th October 2006 11:10 UTC
Thanks kichik, but that is not what I'm looking for. I already have some time information inside the NSIS archive but I want to distinct the generated NSIS archives by their names and therefore I need something like a timestamp in the filename.
Regards,
Michael
kichik
20th October 2006 11:24 UTC
The generated file can have something like:
!define MYTIMESTAMP "something smoething"
You can then use that define with OutFile:
OutFile "my-setup-${MYTIMESTAMP}.exe"
helios73
22nd October 2006 17:23 UTC
Thank you kichik for the hint.
I added the following code to my ant build script:
...
<tstamp/>
<echo file="${nsis.dir}\OutfileTimestamp.nsh" append="false">!define MYTIMESTAMP "${DSTAMP}_${TSTAMP}"
</echo>
...
and to the nsi script I added:
...
!include OutfileTimestamp.nsh
OutFile "setup_${PRODUCT_NAME}_${PRODUCT_VERSION}_${MYTIMESTAMP}.exe"
...
Regards,
Michael
mutantbc
27th February 2007 02:17 UTC
Hi,
I am having problem when renaming the file to output a filename with datetime.
1.) i was able to create a file without datetime e.g. myfile.dat
2.) i was able to rename myfile.dat to myfile-101109 27 Feb, 2007.dat
3.) i cant rename the myfile.dat anymore, why?
!define /date DATE "%H:%M:%S %d %b, %Y"
IfFileExists $MyFilePath lbl_backupFile lbl_end
lbl_backupFile:
Rename $MyFiletPath "$R9\backup\myfile-${DATE}.dat"
lbl_end:
...exit the program
pengyou
27th February 2007 10:49 UTC
i cant rename the myfile.dat anymore, why?
Your code is trying to use an invalid name when it renames the file.
Instead of using a name like "myfile-101109 27 Feb, 2007.dat", your code tries to rename the file to something like "myfile-10:38:36 27 Feb, 2007.dat"
Try changing
!define /date DATE "%H:%M:%S %d %b, %Y"
to
!define /date DATE "%H-%M-%S %d %b, %Y"
so your code will rename the file to something like "myfile-10-42-06 27 Feb, 2007.dat"
mutantbc
28th February 2007 00:53 UTC
I have tried that, but still step 3 doesnt work. I dont know why, step 1 and 2 are working ok.
mutantbc
1st March 2007 08:03 UTC
any help on this one?
kichik
1st March 2007 19:23 UTC
Are you sure that's really what you want to do? DATE will contain the date when you compiled the installer and not the current date on the user's machine... You should get the date at runtime using one of the available functions.
As for the renaming issue, did you create the backup folder first?
ChrisMorton75
21st March 2007 20:09 UTC
syntax information
It's hard to search for special characters for an explanation of how they are used.
Can someone explain the use of the forward-slash in
!define /date DATE "%H:%M:%S"
Is /date calling an NSIS command or an OS command (and if so why isn't "!system" used ) ?
kichik
21st March 2007 20:58 UTC
/date is a switch for the !define command.
ChrisMorton75
21st March 2007 21:03 UTC
thanks for the information