Mathematica mini-memo: Including time stamps in filenames

The following saves data with a time stamp in the filename (this code uses a dialog window to allow the user to add to the filename, e.g. 2012661131myfile.dat):

In[] >> date = DateList[]
Out[]>> {2012,6,6,11,31,16.3462}
In[] >> condate = StringJoin[IntegerString[date[[1;;5]]]]
Out[]>> 2012661131
In[] >> DialogInput[{
   Row[{ TextCell["filename /.../data/"<>condate],
     InputField[Dynamic[[fname], String],TextCell[".dat"]}],
In[] >> saveas="/.../data/"<> concatdate <> fname <> ".dat"
Out[]>> "/.../data/2012661130myfile.dat"
In[] >> Export[saveas, {data1, data2}];

There may be a better way to do this (probably a glaringly obvious one), or even a built in Mathematica function. I would appreciate comments from people to whom I appear an idiot.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s