cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mkapasi
Level 4

Renaming a file with a timestamp extension

Hi,
I want to rename a file on a subsequent install with a timestamp at the end. Is there a variable in ISMP that I can use or will i need to write a custom bean that will do that?
I know java.util.Date will get me the timestamp but i wanted to know if I could use the Move file Action and rename the file to Filename_[Some timestamp property].
Thanks,
-mkapasi
Labels (1)
0 Kudos
(10) Replies
RobertDickau
Flexera Alumni

I haven't tried it, but perhaps in your custom bean make up a Java system property that contains the date (using System.setProperty("TIMESTAMP", timestring)), and then use $J(TIMESTAMP) as part of the target file name?
0 Kudos
mkapasi
Level 4

I tried that but $P will not get me a java system property right? Is there a way to create and set a global variable from my product action which i can later access via $V resolver? I could not find the api to do that. Is there a link available to the javadocs for installshield classes?
Please help.
Thanks,
-mkapasi
0 Kudos
RobertDickau
Flexera Alumni

Sorry, I mean $J to get a Java system property, and not $P.

(In any case, the APIs command under the Help menu gives you access to the API documentation.)
0 Kudos
mkapasi
Level 4

But $J also does not get all the system properties does it? It only gets user.home, user.dir etc. I don't think it can get any system property...atleast not by the syntax $J(TIMESTAMP).
I tried that but that did not resolve.
Anything else i can try?
0 Kudos
RobertDickau
Flexera Alumni

Yes, you should be able to use $J with a custom property that you've defined; is the issue that the value is blank, or that it still reads $J(propname)? If it still includes $J, then the field doesn't resolve any string-resolution expressions, and therefore $V, etc., wouldn't help...
0 Kudos
mkapasi
Level 4

The problem is that the value is blank.
I am setting it in my custom bean as System.setProperty("TIMESTAMP",mytimestring)
and then in my MoveFile product action (which comes after my custom bean) I set the target file to $N($P(absoluteinstalllocation)/mylogfile_$J(TIMESTAMP).log)
-Mkapasi
0 Kudos
RobertDickau
Flexera Alumni

That's strange; if you place $J(TIMESTAMP) on (say) a dialog box that appears after your custom bean, does the value appear?

And how are you setting "mytimestring"?
0 Kudos
mkapasi
Level 4

I did not try it on the dialog box but I was trying to set this property from withing a product action. As soon as I changed the code to extend a wizardaction instead it started working.
Is there no way to set a property from within a product action such that it can be used later by another product action?
Do you always need to use wizard actions to set some temporary properties?
My problem is solved but I would like to know the answers to these questions if you have them
0 Kudos
RobertDickau
Flexera Alumni

As long as the action that sets the custom Java property occurs earlier in the product tree than the action that uses the value, it seems it should work...
0 Kudos
enanrum
Level 9

Nothing for Nothing but why wouldn't you just use variables for your Source and Target in your Move Files action and set them in a CA or the Property Manager!

SOURCE = $V(OLD)
TARGET = $V(NEW)

You can set OLD and NEW vars in the properties manager and only set the Extenstion or the timestamp in a Custom Action using setVariableValue:

OLD --> $P(absoluteInstallLocation)/pathtooldfile/oldfilename
NEW -->$P(absoluteInstallLocation)/pathtooldfile/oldfilename.$V(EXTENSION)

Regards,
Tom
0 Kudos