<?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 Loop Saving Files in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Loop-Saving-Files/m-p/356986#M60705</link>
    <description>&lt;P&gt;Hi, I have a script where a file saves to a particular location. I am saving data files as a string of the product lot number and raw data. I want to be able to run the script multiple times for the same lot number without the files saving over themselves. I want to create some sort of loop that if the file name already exists, then it will save as&amp;nbsp; lotnumber Raw Data (1), lotnumber Raw Data (2) etc. This is what I have coded now, but I don't know how to make a loop with it. Can someone help make this a loop please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;lotnumer = 1234;

path = "C:\Users\Desktop\JMP\";

rawdatafile = (path || "_" || lotnumber || " Raw Data.jmp");

If( File Exists( rawdatafile ),
    dt &amp;lt;&amp;lt; save as( path || "_" || lotnumber || " Raw Data (1).jmp" ),
    dtrlu &amp;lt;&amp;lt; save as( path || "_" || lotnumber || " Raw Data.jmp" )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 22:05:38 GMT</pubDate>
    <dc:creator>B1234</dc:creator>
    <dc:date>2023-06-09T22:05:38Z</dc:date>
    <item>
      <title>Loop Saving Files</title>
      <link>https://community.jmp.com/t5/Discussions/Loop-Saving-Files/m-p/356986#M60705</link>
      <description>&lt;P&gt;Hi, I have a script where a file saves to a particular location. I am saving data files as a string of the product lot number and raw data. I want to be able to run the script multiple times for the same lot number without the files saving over themselves. I want to create some sort of loop that if the file name already exists, then it will save as&amp;nbsp; lotnumber Raw Data (1), lotnumber Raw Data (2) etc. This is what I have coded now, but I don't know how to make a loop with it. Can someone help make this a loop please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;lotnumer = 1234;

path = "C:\Users\Desktop\JMP\";

rawdatafile = (path || "_" || lotnumber || " Raw Data.jmp");

If( File Exists( rawdatafile ),
    dt &amp;lt;&amp;lt; save as( path || "_" || lotnumber || " Raw Data (1).jmp" ),
    dtrlu &amp;lt;&amp;lt; save as( path || "_" || lotnumber || " Raw Data.jmp" )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:05:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Loop-Saving-Files/m-p/356986#M60705</guid>
      <dc:creator>B1234</dc:creator>
      <dc:date>2023-06-09T22:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Saving Files</title>
      <link>https://community.jmp.com/t5/Discussions/Loop-Saving-Files/m-p/357007#M60706</link>
      <description>&lt;P&gt;Here is a simple example that loops until no matching file is found, and then saves the file under a new incremented&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;lotnumer = "1234";

path = "C:\Users\Desktop\JMP\"; 

rawdatafile = (path || "_" || lotnumber || " Raw Data.jmp");

If( File Exists( rawdatafile ),
	i = 1;
	While(
		File Exists(
			path || "_" || lotnumber || " Raw Data (" || Char( i ) ||  ").jmp"),
		i++
	);
	dt &amp;lt;&amp;lt; save as( path || "_" || lotnumber || " Raw Data (" || Char( i ) ||  ").jmp" );
,
	dtrlu &amp;lt;&amp;lt; save as( path || "_" || lotnumber || " Raw Data.jmp" )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Feb 2021 11:09:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Loop-Saving-Files/m-p/357007#M60706</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-02-08T11:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Saving Files</title>
      <link>https://community.jmp.com/t5/Discussions/Loop-Saving-Files/m-p/358445#M60848</link>
      <description>This is exactly what I needed! Thank you!</description>
      <pubDate>Fri, 12 Feb 2021 08:43:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Loop-Saving-Files/m-p/358445#M60848</guid>
      <dc:creator>B1234</dc:creator>
      <dc:date>2021-02-12T08:43:33Z</dc:date>
    </item>
  </channel>
</rss>

