<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic File Saving and Overwriting in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/File-Saving-and-Overwriting/m-p/460058#M70498</link>
    <description>&lt;P&gt;I have a JSL scripts that opens and closes serval sheets. While they're open, it merges the documents into a single file, then saves the file into a local folder. The script currently overwrites the existing file in the local folder. Is there a script that would populate a new file in a subfolder (ideally, distinguished by tagging the a timestamp of creation onto the title "Merged") every time the script is run, instead of overwriting the current one? Or better yet, it's ok if the current one is over written, but a copy of it gets saved into a subfolder every time the script is run? Sort of like a back log I can look at but others can only see the "live" version&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;, I've seen you help here with something similar:&amp;nbsp;&lt;LI-MESSAGE title="Save new graph instead of overwriting the already saved ones" uid="54078" url="https://community.jmp.com/t5/Discussions/Save-new-graph-instead-of-overwriting-the-already-saved-ones/m-p/54078#U54078" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe it's a variation of this?&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:43:59 GMT</pubDate>
    <dc:creator>Arocha1</dc:creator>
    <dc:date>2023-06-10T23:43:59Z</dc:date>
    <item>
      <title>File Saving and Overwriting</title>
      <link>https://community.jmp.com/t5/Discussions/File-Saving-and-Overwriting/m-p/460058#M70498</link>
      <description>&lt;P&gt;I have a JSL scripts that opens and closes serval sheets. While they're open, it merges the documents into a single file, then saves the file into a local folder. The script currently overwrites the existing file in the local folder. Is there a script that would populate a new file in a subfolder (ideally, distinguished by tagging the a timestamp of creation onto the title "Merged") every time the script is run, instead of overwriting the current one? Or better yet, it's ok if the current one is over written, but a copy of it gets saved into a subfolder every time the script is run? Sort of like a back log I can look at but others can only see the "live" version&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;, I've seen you help here with something similar:&amp;nbsp;&lt;LI-MESSAGE title="Save new graph instead of overwriting the already saved ones" uid="54078" url="https://community.jmp.com/t5/Discussions/Save-new-graph-instead-of-overwriting-the-already-saved-ones/m-p/54078#U54078" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe it's a variation of this?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:43:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/File-Saving-and-Overwriting/m-p/460058#M70498</guid>
      <dc:creator>Arocha1</dc:creator>
      <dc:date>2023-06-10T23:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: File Saving and Overwriting</title>
      <link>https://community.jmp.com/t5/Discussions/File-Saving-and-Overwriting/m-p/460096#M70500</link>
      <description>&lt;P&gt;Both options are possible with little bit of scripting. You can easily get "timestamp" by using Today().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is fairly simple example how you could do just saving with timestamp:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

table_name = dt &amp;lt;&amp;lt; get name;
timestamp = Today();
save_path = Eval Insert("$temp\^timestamp^_^table_name^.jmp");
dt &amp;lt;&amp;lt; Save(save_path);
Open("$temp");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With saving to other folder, you could just do two saves with different paths and filenames or copy the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 21:28:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/File-Saving-and-Overwriting/m-p/460096#M70500</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-02-10T21:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: File Saving and Overwriting</title>
      <link>https://community.jmp.com/t5/Discussions/File-Saving-and-Overwriting/m-p/460098#M70502</link>
      <description>&lt;P&gt;You can use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rc = Copy File( from, to );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to copy the file.&amp;nbsp; Look in the Script Editor for the details and a good example on the Copy File&lt;/P&gt;
&lt;P&gt;Once you copy the file to your desired sub directory you can simply use&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;data table("table name") &amp;lt;&amp;lt; Save ("file path" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to save the new table.&amp;nbsp; In the file path, you give the the path and the complete file name, including the .jmp extension.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 21:44:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/File-Saving-and-Overwriting/m-p/460098#M70502</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-02-10T21:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: File Saving and Overwriting</title>
      <link>https://community.jmp.com/t5/Discussions/File-Saving-and-Overwriting/m-p/460341#M70518</link>
      <description>&lt;P&gt;Thanks jthi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script works great, except the timestamp is populating values like "3727386650" before the table name. I tried making timestamp:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timestamp = As Date( Today() );&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To populate the date and time, but the script was unable to save the file.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Feb 2022 17:48:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/File-Saving-and-Overwriting/m-p/460341#M70518</guid>
      <dc:creator>Arocha1</dc:creator>
      <dc:date>2022-02-11T17:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: File Saving and Overwriting</title>
      <link>https://community.jmp.com/t5/Discussions/File-Saving-and-Overwriting/m-p/460346#M70519</link>
      <description>&lt;P&gt;Today() does generate timestamp, but it is in JMP date time value &lt;A href="https://community.jmp.com/t5/JMPer-Cable/Using-dates-times-datetimes-and-durations-in-JMP/ba-p/68689" target="_self"&gt; Using dates, times, datetimes and durations in JMP&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use AsDate() it will most likely have some characters which are not allowed in filenames. What type of format do you want? You can build it from the datetime Today() gives you, check out Scripting Index and Date Time part:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1644603356799.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/39930i1CCBE3F34B16A4D0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1644603356799.png" alt="jthi_0-1644603356799.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;From there you can find functions like Year(), Month(), Day(), Hour(), Minute() and Second() with these (combined with Char() or Eval Insert() you can build most robust version of the timestamp you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&lt;/P&gt;
&lt;P&gt;This is a bit of long code, but it should be fairly robust and basically give you YYYYMMDD_hhmmss formatted string&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

cur_time = Today();
yyyy = char(Year(cur_time));
//add spanning

mm = char(Month(cur_time));
mm = Substr("00", 1, 2 - Length(mm)) || mm;
dd = char(Day(cur_time));
dd = Substr("00", 1, 2 - Length(dd)) || dd;
hh = char(Hour(cur_time));
hh = Substr("00", 1, 2 - Length(hh)) || hh;
min = char(Minute(cur_time));
min = Substr("00", 1, 2 - Length(min)) || min;
ss = char(Second(cur_time));
ss = Substr("00", 1, 2 - Length(ss)) || ss;

timestamp_str = yyyy || mm || dd ||"_"|| hh || min || ss;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Feb 2022 18:27:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/File-Saving-and-Overwriting/m-p/460346#M70519</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-02-11T18:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: File Saving and Overwriting</title>
      <link>https://community.jmp.com/t5/Discussions/File-Saving-and-Overwriting/m-p/460351#M70520</link>
      <description>&lt;P&gt;Worked like a charm! Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 11 Feb 2022 20:57:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/File-Saving-and-Overwriting/m-p/460351#M70520</guid>
      <dc:creator>Arocha1</dc:creator>
      <dc:date>2022-02-11T20:57:20Z</dc:date>
    </item>
  </channel>
</rss>

