Login  Register

Re: using Directory to aim File.open

Posted by Ben G on Nov 08, 2008; 3:24am
URL: http://imagej.273.s1.nabble.com/using-Directory-to-aim-File-open-tp3694574p3694578.html

Michael,

This one did the trick.  I didn't know about the call functions in
macros.  A newbe will not trip over it in any of the documentation,
which is pretty thin.  I looked at the Call Demo program by Johannes
Schindelin and your suggestion and finally came up with

myDirectory = "/home/ben/inputfiles1/";
call("ij.io.OpenDialog.setDefaultDirectory", myDirectory);
path = File.openDialog("Select a Data File");

and it worked perfectly.

Thanks for the help,

Ben Gravely
----------------------------------------------------

Michael Schmid-3 (via Nabble) wrote:

> Hi Ben,
>
> in a macro you could try something like this:
>
>    myDirectory = "/home/ben/inputfiles1/";
>    call("ij.io.OpenDialog.setDefaultDirectory", myDirectory);
>
> The separator (slash) at the end of myDirectory is optional.
>
> You can also get the current default:
>    currentDirectory = call("ij.io.OpenDialog.getDefaultDirectory");
>
> Michael
> ________________________________________________________________
>
> On 6 Nov 2008, at 16:29, Ben G wrote:
>
> > 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.
> >>
> >>
> >
> > --
> > View this message in context: http://n2.nabble.com/using-Directory- 
> > to-aim-File.open-tp1461268p1465323.html
> > Sent from the ImageJ mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------
> This email is a reply to your post @
> http://n2.nabble.com/using-Directory-to-aim-File.open-tp1461268p1465658.html
> You can reply by email or by visting the link above.
>