File list query

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

File list query

JimmiB
Hi all,

I am wondering whether there is a way to specify the order
that files or folders are opened/used.

For example if we consider;

dir1 = getDirectory("Choose Source Directory ");
Expt = getFileList(dir1);
for (v=0; v<Expt.length; v++)
print (Expt[v]);

I would have thought that the list would be ordered by the
name of the files or folders in the list.

However, I seem to get a random(ish order)
eg.
251110_pHg4tom_Low frequency_multidose_5/
251110_pHg4tom_Low frequency_multidose_4/
251110_pHg4tom_Low frequency_multidose_3/
251110_pHg4tom_Low frequency_multidose_2/
251110_pHg4tom_Low frequency_multidose_1/

Is there a simple way to specify the order?

Cheers,
James
Reply | Threaded
Open this post in threaded view
|

Re: File list query

Michael Schmid
Hi James,

what about simply sorting the array?
 Array.sort(Expt)

 http://rsb.info.nih.gov/ij/developer/macro/functions.html#Array

Michael
________________________________________________________________
On May 16, 2012, at 08:55, James Burchfield wrote:

> Hi all,
>
> I am wondering whether there is a way to specify the order
> that files or folders are opened/used.
>
> For example if we consider;
>
> dir1 = getDirectory("Choose Source Directory ");
> Expt = getFileList(dir1);
> for (v=0; v<Expt.length; v++)
> print (Expt[v]);
>
> I would have thought that the list would be ordered by the
> name of the files or folders in the list.
>
> However, I seem to get a random(ish order)
> eg.
> 251110_pHg4tom_Low frequency_multidose_5/
> 251110_pHg4tom_Low frequency_multidose_4/
> 251110_pHg4tom_Low frequency_multidose_3/
> 251110_pHg4tom_Low frequency_multidose_2/
> 251110_pHg4tom_Low frequency_multidose_1/
>
> Is there a simple way to specify the order?
>
> Cheers,
> James