Archive: Howto add Timestamp to outfile?


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


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.


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


The generated file can have something like:

!define MYTIMESTAMP "something smoething"
You can then use that define with OutFile:
OutFile "my-setup-${MYTIMESTAMP}.exe"

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


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


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"

I have tried that, but still step 3 doesnt work. I dont know why, step 1 and 2 are working ok.


any help on this one?


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?


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 ) ?


/date is a switch for the !define command.


http://nsis.sourceforge.net/Docs/Chapter5.html#5.4.1


thanks for the information