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 |
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. |
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.
|
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. |
Michael,
Those commands look like Java commands. I haven't found a Call command, or setDefaultDirectory command in the IJ macro language. I don't know the Java language, I can only work in the macro language. I wish there were something like SetDirectory ("/a/b/c/") in IJ macro language. If there is, I haven't been able to find it. Thanks, BenG ---------------------------------------------------- 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. > |
Hi Ben,
these are ImageJ Macro commands. "call" allows you to call a static Java method from a macro. It must be lowercase, not "Call". You need no java programming to use it. http://rsb.info.nih.gov/ij/developer/macro/functions.html#call The macro command "call" is in ImageJ since version 1.37c. --- By the way, another nice way of using the "call" command is saving/ reading preferences for a macro, for keeping them after closing and opening ImageJ. E.g. var par1 = parseInt(call("ij.Prefs.get", "myMacro.parameter1","0")); //read an integer parameter where 0 is the default function setOptions() { Dialog.create("my Macro Options"); Dialog.addNumber("Parameter1", par1); Dialog.show(); par1 = round(Dialog.getNumber()); call("ij.Prefs.set", "myMacro.parameter1",toString(par1)); } Michael ________________________________________________________________ On 7 Nov 2008, at 05:15, Ben G wrote: > Michael, > > Those commands look like Java commands. I haven't found a Call > command, > or setDefaultDirectory command in the IJ macro language. I don't know > the Java language, I can only work in the macro language. > > I wish there were something like SetDirectory ("/a/b/c/") in IJ macro > language. If there is, I haven't been able to find it. > > Thanks, > > BenG > ---------------------------------------------------- > > > > 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. >> > > > -- > View this message in context: http://n2.nabble.com/using-Directory- > to-aim-File.open-tp1461268p1468367.html > Sent from the ImageJ mailing list archive at Nabble.com. |
In reply to this post by Michael Schmid
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. > |
Free forum by Nabble | Edit this page |