0
$\begingroup$

How to save all the variable with a filename containing the Timestamp. For example: If the current time is 2:30:56 PM, The file name should be FileName_143056.

I am currently using

Names["Global`*"] (*Check they're there*)
DumpSave["G:\\Mathematica\\dump.mx", "Global`"];

This worked out

out = FileNameJoin@{$UserDocumentsDirectory, 
   "MathematicaOutput" <> ToString /@ Date[] <> ".mx"}
DumpSave[out, "Global`"]

Source

$\endgroup$
5
  • $\begingroup$ Have you tried anything? It is quite straightoforward with DateString and StringJoin. $\endgroup$
    – Kuba
    Commented Jul 23, 2018 at 13:25
  • $\begingroup$ I google it, Didn't get anything related to it. Will try now using those! $\endgroup$
    – kosa
    Commented Jul 23, 2018 at 13:26
  • $\begingroup$ I tried this: StringJoin[ToString[TimeObject[][[1]][[1]]], ToString[TimeObject[][[1]][[2]]], ToString[(TimeObject[][[1]][[3]])]] $\endgroup$
    – kosa
    Commented Jul 23, 2018 at 13:44
  • $\begingroup$ Why didn;t you use DateString or the linked topic approach? I'm sorry I am confused, what is the line below 'I tried this'. And why do you say it worked out if the result does not match your request? $\endgroup$
    – Kuba
    Commented Jul 23, 2018 at 14:06
  • $\begingroup$ I removed the 'I tried this part'. I tried this, it almost worked. But finally found the answer at the link provided in the source. $\endgroup$
    – kosa
    Commented Jul 23, 2018 at 14:09

0