Login  Register

Re: using Directory to aim File.open

Posted by Ben G on Nov 06, 2008; 3:29pm
URL: http://imagej.273.s1.nabble.com/using-Directory-to-aim-File-open-tp3694574p3694576.html

Mathais,

Thanks for the reply.

In macro language, the two functions you mentioned are
 dir = getDirectory("Choose a Directory ");
 list = getFileList(dir);

Unfortunately, these are not what I am after.  These will show and list files in a directory after you have chosen the directory.  Maybe I was not clear about what I need.

I don't want to choose the directory.  I want the open file commands to go directly to a specific folder that I already know the address of, and let me pick a file from that folder.  I need to switch back and forth between a Data Files folder and an Image Files folder.  I don't want to have to navigate back and forth between folders, I want the appropriate folder open for me to select a file.

I have tried to set the path to the folder using

dir=getDirectory("/path to folderA or B"),

but it doesn't work. It takes me to whatever the last folder was, it doesn't seem to read the path I put inside.






Mathias Dotzel wrote
Hi Ben,

this code helped me doing similar things.

String directoryPath = IJ.getDirectory("Select source folder...");
String[] list = new File(directoryPath).list();

In list you can find all names of the files that are found in the  
folder.

Mathias.

Am 05.11.2008 um 19:25 schrieb Ben G:

> I have a simple task that I can't get to work.
>
> I want to read images from folder 1 and read data files from folder 2.
>
> When I open the get image file dialog, I want it to point to the  
> images
> folder.
> When I open the get data file dialog, I want it to point to the data
> files folder.
>
> So far, no luck.
>
> Thanks
>
> --
> View this message in context: http://n2.nabble.com/using-Directory-to-aim-File.open-tp1461268p1461268.html
> Sent from the ImageJ mailing list archive at Nabble.com.