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 |
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 |
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 |
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 |
Free forum by Nabble | Edit this page |