<?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 Ordering Files in Folder in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Ordering-Files-in-Folder/m-p/404912#M65536</link>
    <description>&lt;P&gt;Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a list of files that I want to concatenate (see first figure).&amp;nbsp; The preference would be to concatenate as shown, that is "surf_12275-87-1..., "surf_12275-87-2...", etc. However, when I form a list from the files in the folder (after stripping off unnecessary characters) , the sequence is "12275-87-&lt;STRONG&gt;1&lt;/STRONG&gt;, 12275-87-&lt;STRONG&gt;10&lt;/STRONG&gt;, 12275-87-&lt;STRONG&gt;11&lt;/STRONG&gt;". The preference however, would be&amp;nbsp;"12275-87-&lt;STRONG&gt;1&lt;/STRONG&gt;, 12275-87-&lt;STRONG&gt;2&lt;/STRONG&gt;, 12275-87-&lt;STRONG&gt;3&lt;/STRONG&gt;". Obviously the straight forward way around the issue is to have the files come to me in the form of " -01, -02, ... -10, -11", but that will not always be the case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a straight forward way to get the files into the preferred ranking format so I can open and concatenate from low to high? Current script attached.&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;s_path = {};
	X_path = {};
	f1 = Files In Directory( SD1, recursive(1));
	
	For( i = 1, i &amp;lt;= N Items( f1 ), i++,
	
			b = f1[i];
			
			c = Contains Item(b, "surf", "_");
			
			If( c==1, 
				d = Word(2, b, "_");
				Insert Into(s_path,d),
				Insert Into(X_path, d)	
			)
				
	);
	
	Show(s_path);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="folder_view.PNG" style="width: 747px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/34618iFE27DA20347F98A6/image-size/large?v=v2&amp;amp;px=999" role="button" title="folder_view.PNG" alt="folder_view.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="actual list.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/34619iDCBB8CAD67F9D10E/image-size/large?v=v2&amp;amp;px=999" role="button" title="actual list.PNG" alt="actual list.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 19:53:34 GMT</pubDate>
    <dc:creator>NRW</dc:creator>
    <dc:date>2023-06-09T19:53:34Z</dc:date>
    <item>
      <title>Ordering Files in Folder</title>
      <link>https://community.jmp.com/t5/Discussions/Ordering-Files-in-Folder/m-p/404912#M65536</link>
      <description>&lt;P&gt;Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a list of files that I want to concatenate (see first figure).&amp;nbsp; The preference would be to concatenate as shown, that is "surf_12275-87-1..., "surf_12275-87-2...", etc. However, when I form a list from the files in the folder (after stripping off unnecessary characters) , the sequence is "12275-87-&lt;STRONG&gt;1&lt;/STRONG&gt;, 12275-87-&lt;STRONG&gt;10&lt;/STRONG&gt;, 12275-87-&lt;STRONG&gt;11&lt;/STRONG&gt;". The preference however, would be&amp;nbsp;"12275-87-&lt;STRONG&gt;1&lt;/STRONG&gt;, 12275-87-&lt;STRONG&gt;2&lt;/STRONG&gt;, 12275-87-&lt;STRONG&gt;3&lt;/STRONG&gt;". Obviously the straight forward way around the issue is to have the files come to me in the form of " -01, -02, ... -10, -11", but that will not always be the case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a straight forward way to get the files into the preferred ranking format so I can open and concatenate from low to high? Current script attached.&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;s_path = {};
	X_path = {};
	f1 = Files In Directory( SD1, recursive(1));
	
	For( i = 1, i &amp;lt;= N Items( f1 ), i++,
	
			b = f1[i];
			
			c = Contains Item(b, "surf", "_");
			
			If( c==1, 
				d = Word(2, b, "_");
				Insert Into(s_path,d),
				Insert Into(X_path, d)	
			)
				
	);
	
	Show(s_path);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="folder_view.PNG" style="width: 747px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/34618iFE27DA20347F98A6/image-size/large?v=v2&amp;amp;px=999" role="button" title="folder_view.PNG" alt="folder_view.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="actual list.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/34619iDCBB8CAD67F9D10E/image-size/large?v=v2&amp;amp;px=999" role="button" title="actual list.PNG" alt="actual list.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:53:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Ordering-Files-in-Folder/m-p/404912#M65536</guid>
      <dc:creator>NRW</dc:creator>
      <dc:date>2023-06-09T19:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Files in Folder</title>
      <link>https://community.jmp.com/t5/Discussions/Ordering-Files-in-Folder/m-p/404938#M65538</link>
      <description>&lt;P&gt;JMP data table seem to be using numerical sorting if you have columns modeling type as ordinal so you could use that or for loop.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

a = {
	"surf_12275_87-1_r250", 
	"surf_12275_87-2_r250", 
	"surf_12275_87-3_r250", 
	"surf_12275_87-4_r250", 
	"surf_12275_87-5_r250", 
	"surf_12275_87-6_r250", 
	"surf_12275_87-7_r250", 
	"surf_12275_87-8_r250", 
	"surf_12275_87-9_r250", 
	"surf_12275_87-10_r250",
	"surf_12275_87-11_r250",
	"surf_12275_87-12_r250",
	"surf_12275_87-13_r250",
	"surf_12275_87-20_r250",
	"surf_12275_87-22_r250"
};
a = Sort List(a); //break the ordering
Show(a);
dt = New Table("",
	New Column("SortList", Character, Ordinal, Set Values(a)), private
);
dt &amp;lt;&amp;lt; Sort(By(:SortList), Order(Ascending), Replace Table);
b = dt:SortList &amp;lt;&amp;lt; Get Values;
Close(dt, no save);
Show(b);

c = {};
For(i = 1, i &amp;lt;= N Items(a), i++,
	Insert Into(c, a[i], Num(Words(a[i], "-_")[4]));
);
Show(c);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;These could give some idea how to approach the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit:&lt;/P&gt;&lt;P&gt;You might be also able to concatenate all tables first together while using Source column, change source column to Ordinal and then sort by that:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
a = {
	"surf_12275_87-1_r250", 
	"surf_12275_87-2_r250", 
	"surf_12275_87-3_r250", 
	"surf_12275_87-4_r250", 
	"surf_12275_87-5_r250", 
	"surf_12275_87-6_r250", 
	"surf_12275_87-7_r250", 
	"surf_12275_87-8_r250", 
	"surf_12275_87-9_r250", 
	"surf_12275_87-10_r250",
	"surf_12275_87-11_r250",
	"surf_12275_87-12_r250",
	"surf_12275_87-13_r250",
	"surf_12275_87-20_r250",
	"surf_12275_87-22_r250"
};
a = Sort List(a);

one = New Table(a[1], new column("a", set values([1])));
two = New Table(a[2], new column("a", set values([10])));
three = New Table(a[6], new column("a", set values([2])));

one &amp;lt;&amp;lt; Concatenate(two, three, Append to first table, Create Source Column);
one:Source Table &amp;lt;&amp;lt; Set Modeling Type("Ordinal");
one &amp;lt;&amp;lt; Sort(By(:Source Table), Order(Ascending), Replace Table);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jul 2021 19:56:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Ordering-Files-in-Folder/m-p/404938#M65538</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-07-28T19:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Files in Folder</title>
      <link>https://community.jmp.com/t5/Discussions/Ordering-Files-in-Folder/m-p/404961#M65543</link>
      <description>&lt;P&gt;Here is one way to sort the list, by taking the elements of the names and separating them into different columns in a data table, changing the numeric elements to numeric columns and then sorting the data table by all of the elements.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

f1={"surf_12275-87-11_r250_50x_mean_2.jmp", "surf_12275-87-2_r250_50x_mean_2.jmp",
"surf_12275-87-10_r250_50x_mean_2.jmp", "surf_12275-87-4_r250_50x_mean_2.jmp",
"surf_12275-87-5_r250_50x_mean_2.jmp", "surf_12275-87-6_r250_50x_mean_2.jmp",
"surf_12275-87-7_r250_50x_mean_2.jmp", "surf_12275-87-8_r250_50x_mean_2.jmp",
"surf_12275-87-9_r250_50x_mean_2.jmp", "surf_12275-87-1_r250_50x_mean_2.jmp",
"surf_12275-87-3_r250_50x_mean_2.jmp"};

dt = new table("Sort Table",
	add rows(nitems(f1)),
	new column("File Names", character)
);
dt:File Names &amp;lt;&amp;lt; set values(f1);

// Create and populate separate columns for each element in the names
sortList = {};
i=1;
While(word(i,f1[1],"_-.") != "",
	dt&amp;lt;&amp;lt;new column("Element" || char(i), character);
	insert into(sortList,"Element" || char(i) );
	For(k=1,k&amp;lt;=nitems(f1),k++,
		column(dt,ncols(dt))[k]=word(i,f1[k],"_-.")
	);
	i++
);

// Find the columns that are numeric and change them to numeric
For(i=2,i&amp;lt;=ncols(dt),i++,
	If(!isMissing(num(column(dt,i)[1])),
		column(dt,i)&amp;lt;&amp;lt;data type(numeric)
	);
);

// Sort the data table
dt&amp;lt;&amp;lt;sort(by(eval(sortList)),replace table(1));

// Reset the f1 list to the sorted list
f1 = dt:File Names &amp;lt;&amp;lt; get values;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am sure other members may have alternative methods.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 20:51:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Ordering-Files-in-Folder/m-p/404961#M65543</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-07-28T20:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Files in Folder</title>
      <link>https://community.jmp.com/t5/Discussions/Ordering-Files-in-Folder/m-p/405915#M65603</link>
      <description>&lt;P&gt;Jarmo,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks for teaching me a new skill set. I've tried all your suggested approaches to improve my coding ability. Here is my latest revision which does exactly what I want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Neil&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;f1 = Files In Directory( SD1, recursive(1));
	
	f1 = Sort List(f1);
	dt = New Table("", 
		New Column("SortList", Character, Ordinal, Set Values(f1)), private	
	);
	
	dt &amp;lt;&amp;lt; Sort( By(:SortList),  Order(Ascending), Replace Table);
	b = dt:SortList &amp;lt;&amp;lt; Get Values;
	Close(dt, no save);
	
	For( i=1, i &amp;lt;= N Items(b), i++,
		
		file_1 = Open(SD1 || b[1]);
		If(i &amp;gt; 1, 
			
			file_nxt = Open(SD1 || b[i], Private);
			file_1 &amp;lt;&amp;lt; Concatenate(file_nxt, Append to first table);	
		)
	);
	
	file_1 &amp;lt;&amp;lt; Save(SD1 || "All Summary");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Jul 2021 15:33:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Ordering-Files-in-Folder/m-p/405915#M65603</guid>
      <dc:creator>NRW</dc:creator>
      <dc:date>2021-07-30T15:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Files in Folder</title>
      <link>https://community.jmp.com/t5/Discussions/Ordering-Files-in-Folder/m-p/405916#M65604</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't tell you how insightful this approach was for another (unrelated to this thread) problem I was having. That is, file names with unpredicted "element" arrangements. At least I'm able to dissect the filenames and "reorder" to consistent labeling.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for all your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Neil&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 15:41:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Ordering-Files-in-Folder/m-p/405916#M65604</guid>
      <dc:creator>NRW</dc:creator>
      <dc:date>2021-07-30T15:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering Files in Folder</title>
      <link>https://community.jmp.com/t5/Discussions/Ordering-Files-in-Folder/m-p/406714#M65681</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5080"&gt;@DonMcCormack&lt;/a&gt;this could also be a possible option for a JMP Challenge: &lt;A href="https://blog.codinghorror.com/sorting-for-humans-natural-sort-order/" target="_blank" rel="noopener"&gt;Natural Sorting&lt;/A&gt; . I usually try to handle situations like this with additional padded zeros when I can, but it is quite common for them to be missing...&lt;/P&gt;</description>
      <pubDate>Tue, 03 Aug 2021 19:33:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Ordering-Files-in-Folder/m-p/406714#M65681</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-08-03T19:33:15Z</dc:date>
    </item>
  </channel>
</rss>

