Re: macro command to designate but not open a file?

Posted by Aryeh Weiss on
URL: http://imagej.273.s1.nabble.com/macro-command-to-designate-but-not-open-a-file-tp5014926p5014938.html

On 12/11/2015 5:00 PM, Bill Christens-Barry wrote:
> In a macro I'd like to navigate to and choose but not open a file so I can assign its name (or full path) to a variable. I haven't identified a means of doing this using the File.* or getDirectory() macro commands. Is there a way to do this?
Try this:


inputPath = File.openDialog("choose an image file");

if (inputPath == "") {
     exit("User canceled the dialog");
}
inputName = File.getName(inputPath);
inputDir = File.getParent(inputPath);
print(inputPath);
print(inputDir);
print(inputName);
inputPrefix = substring(inputName, 0, lastIndexOf(inputName, "."));
print(inputPrefix);

> Also, I'd like to specify a default starting path for the getDirectory() macro command, but don't see a way to do this. Is there a means for doing this in the macro language?
Dont know about this, but maybe you can do it with the dialog commands.
> Thanks,
>
> Bill
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>


--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051

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