using getFileList to obtain an array of files arranged by creation date

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

using getFileList to obtain an array of files arranged by creation date

Ximo Soriano
Hi there!I would like getFileList to get the name of the files in a directory arranged by file creation date.I'm running imageJ on a windows OS.Any idea on how to do so?Thanks a lot in advance.Bests.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: using getFileList to obtain an array of files arranged by creation date

Jerome Mutterer-3
Hi,

You can use File.lastModified and array ranks to achieve this.
Note, however that this is last modification date and not creation date.

dir = getDirectory("choose dir");
list = getFileList(dir);
dates = newArray(list.length);
for (i=0;i<list.length;i++) {
  dates[i] = File.lastModified(dir+list[i]);
}
ranks = Array.rankPositions(dates);
for (i=0;i<list.length;i++) {
  print (dates[ranks[i]],list[ranks[i]]);
}


Jerome.


2018-07-28 15:55 GMT+02:00 Ximo Soriano <
[hidden email]>:
>
> Hi there!I would like getFileList to get the name of the files in a
directory arranged by file creation date.I'm running imageJ on a windows
OS.Any idea on how to do so?Thanks a lot in advance.Bests.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html




--
Jerome Mutterer
CNRS - Institut de biologie moléculaire des plantes
12, rue du Général Zimmer
67084 Strasbourg Cedex
www.ibmp.cnrs.fr

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html