<?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 Re: JSL script Open latest version file in the folder in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-script-Open-latest-version-file-in-the-folder/m-p/81933#M37020</link>
    <description>&lt;P&gt;You can use&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Files in Directory()&lt;/P&gt;
&lt;P&gt;to get all of the files in a directory.&lt;/P&gt;
&lt;P&gt;And then using Ian's code, you can loop across all of the files and get the file with the latest date in it's name,&lt;/P&gt;
&lt;P&gt;and/or, you can use the&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Last Modification Date()&lt;/P&gt;
&lt;P&gt;function to find the last time each specific file was modified&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Format(
	Last Modification Date(
		"$SAMPLE_DATA/Big Class.jmp"
	),
	"ddmonyyyy:h:m:s"
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 30 Oct 2018 12:00:14 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2018-10-30T12:00:14Z</dc:date>
    <item>
      <title>JSL script Open latest version file in the folder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-script-Open-latest-version-file-in-the-folder/m-p/81908#M37010</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to automate the script where it will automatically open the latest file based on latest date in the file name and latest modified date in a specific folder which shown in the picture below. How can I do this?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Pic1.JPG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/14100i88B911F74B531C3B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Pic1.JPG" alt="Pic1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 07:24:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-script-Open-latest-version-file-in-the-folder/m-p/81908#M37010</guid>
      <dc:creator>ReginaHong</dc:creator>
      <dc:date>2018-10-30T07:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: JSL script Open latest version file in the folder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-script-Open-latest-version-file-in-the-folder/m-p/81921#M37012</link>
      <description>&lt;P&gt;Looks like there are two requirements here - To get the file creation date (encoded in the file name), and to get the last time this file was modified (from the operating system).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the first of these, you could try starting from the JSL below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);

// Given a file name constructed in a particular way, returns the encoded creation date
getDateFromFileName = 
Function({fName}, {Default Local},
	pieces = Words(fName, "-");
	pieces[1] = Substr(pieces[1], 8, 2);								// Get the 'day'
	pieces[3] = Substr(pieces[3], 1, 4);								// Get the 'year'
	dt = Num(Informat(pieces[1]||pieces[2]||pieces[3], "DDMonYYY"));	// Get the JMP datetime from the pieces
	);

fName = "Testing01-Nov-2018_.xlsx";	
dt = getDateFromFileName(fName);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that how robust this kind of code is will depend crucially on what you can (and can't) safely assume about how the file name is constructed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get the last time a file was modified, you may need to look at 'Run Program' (search for this in 'Help &amp;gt; Scripting Index').&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 10:52:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-script-Open-latest-version-file-in-the-folder/m-p/81921#M37012</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2018-10-30T10:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: JSL script Open latest version file in the folder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-script-Open-latest-version-file-in-the-folder/m-p/81930#M37018</link>
      <description>&lt;P&gt;The File - Import Multiple file command can add a column or filter based on the last modified date. You could point it at the folder, read in all the data and then just keep the file with the newest date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Multiple File Import(
	&amp;lt;&amp;lt;Set Folder( "C:\Testing\" ),
	&amp;lt;&amp;lt;Set Name Filter( "*.*;" ),
	&amp;lt;&amp;lt;Set Name Enable( 0 ),
	&amp;lt;&amp;lt;Set Size Filter( {162, 4814056} ),
	&amp;lt;&amp;lt;Set Size Enable( 0 ),
	&amp;lt;&amp;lt;Set Date Filter( {3606508609.82052, 3623302732.269} ),
	&amp;lt;&amp;lt;Set Date Enable( 0 ),
	&amp;lt;&amp;lt;Set Add File Name Column( 0 ),
	&amp;lt;&amp;lt;Set Add File Size Column( 0 ),
	&amp;lt;&amp;lt;Set Add File Date Column( 1 ),
	&amp;lt;&amp;lt;Set Import Mode( "CSVData" ),
	&amp;lt;&amp;lt;Set Charset( "Best Guess" ),
	&amp;lt;&amp;lt;Set Stack Mode( "Stack Similar" ),
	&amp;lt;&amp;lt;Set CSV Has Headers( 1 ),
	&amp;lt;&amp;lt;Set CSV Allow Numeric( 1 ),
	&amp;lt;&amp;lt;Set CSV First Header Line( 1 ),
	&amp;lt;&amp;lt;Set CSV Number Of Header Lines( 1 ),
	&amp;lt;&amp;lt;Set CSV First Data Line( 2 ),
	&amp;lt;&amp;lt;Set CSV EOF Comma( 1 ),
	&amp;lt;&amp;lt;Set CSV EOF Tab( 0 ),
	&amp;lt;&amp;lt;Set CSV EOF Space( 0 ),
	&amp;lt;&amp;lt;Set CSV EOF Spaces( 0 ),
	&amp;lt;&amp;lt;Set CSV EOF Other( "" ),
	&amp;lt;&amp;lt;Set CSV EOL CRLF( 1 ),
	&amp;lt;&amp;lt;Set CSV EOL CR( 1 ),
	&amp;lt;&amp;lt;Set CSV EOL LF( 1 ),
	&amp;lt;&amp;lt;Set CSV EOL Semicolon( 0 ),
	&amp;lt;&amp;lt;Set CSV EOL Other( "" ),
	&amp;lt;&amp;lt;Set CSV Quote( "\!"" ),
	&amp;lt;&amp;lt;Set CSV Escape( "" )
) &amp;lt;&amp;lt; Import Data&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Oct 2018 11:42:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-script-Open-latest-version-file-in-the-folder/m-p/81930#M37018</guid>
      <dc:creator>stephen_pearson</dc:creator>
      <dc:date>2018-10-30T11:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: JSL script Open latest version file in the folder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-script-Open-latest-version-file-in-the-folder/m-p/81933#M37020</link>
      <description>&lt;P&gt;You can use&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Files in Directory()&lt;/P&gt;
&lt;P&gt;to get all of the files in a directory.&lt;/P&gt;
&lt;P&gt;And then using Ian's code, you can loop across all of the files and get the file with the latest date in it's name,&lt;/P&gt;
&lt;P&gt;and/or, you can use the&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Last Modification Date()&lt;/P&gt;
&lt;P&gt;function to find the last time each specific file was modified&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Format(
	Last Modification Date(
		"$SAMPLE_DATA/Big Class.jmp"
	),
	"ddmonyyyy:h:m:s"
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Oct 2018 12:00:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-script-Open-latest-version-file-in-the-folder/m-p/81933#M37020</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-10-30T12:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: JSL script Open latest version file in the folder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-script-Open-latest-version-file-in-the-folder/m-p/81935#M37022</link>
      <description>&lt;P&gt;Many thanks Jim - I overlooked 'Last Modifcation Date()', so it's good to know about it . . .&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 12:04:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-script-Open-latest-version-file-in-the-folder/m-p/81935#M37022</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2018-10-30T12:04:01Z</dc:date>
    </item>
  </channel>
</rss>

