Login  Register

Re: getDirectory command does not show files

Posted by Jerome Mutterer-3 on Jan 19, 2015; 7:58am
URL: http://imagej.273.s1.nabble.com/getDirectory-command-does-not-show-files-tp5011272p5011276.html

Hi,
To get the list of files, use getFileList(dir); function that returns an
array.
dir = getDirectory("Choose a directory");
list = getFileList(dir);

Jerome


On 19 January 2015 at 07:30, Patrick Coffey <[hidden email]> wrote:

> Thanks for your answer. Ultimately I was trying to get a "list" of files
> in the directory that is selected by the user.
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Thomas Peterbauer
> Sent: Sunday, January 18, 2015 10:09 PM
> To: [hidden email]
> Subject: Re: getDirectory command does not show files
>
> It's not a bug, it's a feature. With 'getDirectory(string)', the user is
> asked to choose a directory, so there's no sense in displaying normal
> files. If you want a normal file chooser displaying everything (files and
> folders), use 'File.openDialog(title)'.
>
> On 2015-01-18 20:52, Patrick Coffey wrote:
> > I'm using the getDirectory("") command and the dialog window shows up
> but only folders, not files appear in the window. For instance, the example
> below won't show the files (only folders) in the dialog window. This is
> happening on two different versions of imageJ and two different computers.
> Not sure what the problems is ... settings? Help appreciated!!
> >
> > macro "Batch Measure" {
> >      dir = getDirectory("Choose a Directory ");
> >      list = getFileList(dir);
> >      if (getVersion>="1.40e")
> >          setOption("display labels", true);
> >      setBatchMode(true);
> >      for (i=0; i<list.length; i++) {
> >          path = dir+list[i];
> >          showProgress(i, list.length);
> >          if (!endsWith(path,"/")) open(path);
> >          if (nImages>=1) {
> >              run("Measure");
> >              close();
> >          }
> >      }
> > }
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> 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
T 0367155339
www.ibmp.cnrs.fr

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