cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
prmiszkiewicz
Level II

Include current date in name of saved file?

I have a script which saves results to PDF file with a name specified in the script by using save pdf command. Currently I have to manually adjusst the file name so that the older one doesn't get overwritten as the script is run every few days. Is there any way to include the current date in the file name in an automatic way?

1 ACCEPTED SOLUTION

Accepted Solutions
Byron_JMP
Staff

Re: Include current date in name of saved file?

Here's an example where a table is opened and saved with the current date. The last line saves the table with today's date embedded in it.

Also, Its important to pick a date format that doesn't have a "/" or a ":" in it.

//Earth Quates, last 7 days

Names Default To Here( 1 );

cd=get default directory();

data=expr(quake = Open(

  //"/0000000027230BB0/eqs7day-M1.txt",

  "http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M1.txt",

  columns(

  Src = Character,

  Eqid = Character,

  Version = Character,

  Datetime = Character,

  Lat = Numeric,

  Lon = Numeric,

  Magnitude = Numeric,

  Depth = Numeric,

  NST = Numeric,

  Region = Character

  ),

  Import Settings(

  End Of Line( CRLF, CR, LF ),

  End Of Field( Comma ),

  Strip Quotes( 1 ),

  Use Apostrophe as Quotation Mark( 0 ),

  Scan Whole File( 1 ),

  Treat empty columns as numeric( 0 ),

  Labels( 1 ),

  Column Names Start( 1 ),

  Data Starts( 3 ),

  Lines To Read( All ),

  Year Rule( "20xx" )

  )

);

quake<< set name("Earthquakes "||short date(today()));

quake<< new column("DateTime2", <<format("m/d/y h:m:s"),

  formula(

  l = Words( :Datetime, " ," );

  d = l[3] || Substr( l[2], 1, 3 ) || l[4] || " " || l[5];

  Informat( d, "ddMonyyyy h:m:s" );

  )

  ););

data;

quake << Save as( cd||"Earthquakes "||Format Date( Today(), "ddmonyyyy" )||".jmp" );

JMP Systems Engineer, Health and Life Sciences (Pharma)

View solution in original post

2 REPLIES 2
Byron_JMP
Staff

Re: Include current date in name of saved file?

Here's an example where a table is opened and saved with the current date. The last line saves the table with today's date embedded in it.

Also, Its important to pick a date format that doesn't have a "/" or a ":" in it.

//Earth Quates, last 7 days

Names Default To Here( 1 );

cd=get default directory();

data=expr(quake = Open(

  //"/0000000027230BB0/eqs7day-M1.txt",

  "http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M1.txt",

  columns(

  Src = Character,

  Eqid = Character,

  Version = Character,

  Datetime = Character,

  Lat = Numeric,

  Lon = Numeric,

  Magnitude = Numeric,

  Depth = Numeric,

  NST = Numeric,

  Region = Character

  ),

  Import Settings(

  End Of Line( CRLF, CR, LF ),

  End Of Field( Comma ),

  Strip Quotes( 1 ),

  Use Apostrophe as Quotation Mark( 0 ),

  Scan Whole File( 1 ),

  Treat empty columns as numeric( 0 ),

  Labels( 1 ),

  Column Names Start( 1 ),

  Data Starts( 3 ),

  Lines To Read( All ),

  Year Rule( "20xx" )

  )

);

quake<< set name("Earthquakes "||short date(today()));

quake<< new column("DateTime2", <<format("m/d/y h:m:s"),

  formula(

  l = Words( :Datetime, " ," );

  d = l[3] || Substr( l[2], 1, 3 ) || l[4] || " " || l[5];

  Informat( d, "ddMonyyyy h:m:s" );

  )

  ););

data;

quake << Save as( cd||"Earthquakes "||Format Date( Today(), "ddmonyyyy" )||".jmp" );

JMP Systems Engineer, Health and Life Sciences (Pharma)
prmiszkiewicz
Level II

Re: Include current date in name of saved file?

Thank you very much, I'm new to JMP, so didn't think it will work almiost in same way like in C++