Login  Register

Re: how to get name of arbitrary file selected by user in macro?

Posted by Wayne Rasband on Apr 27, 2007; 6:56pm
URL: http://imagej.273.s1.nabble.com/how-to-get-name-of-arbitrary-file-selected-by-user-in-macro-tp3699653p3699654.html

In ImageJ 1.38q, which is now available, the File.name and
File.directory macro functions return the name and directory path of
the last file opened using open(), saveAs(), File.open() or
File.openAsString(). Here is an example:

     str = File.openAsString("");
     print("Name: "+File.name);
     print("Directory: "+File.directory);

-wayne

On Apr 25, 2007, at 12:28 PM, Bill Christens-Barry wrote:

> How can I get the name and path of a text file opened by the user in a
> macro?
> The macro opens the file this way:
>
> f = File.openAsString("");
>
> After looking at the list archives and online doc, I haven't figured
> out how to
> get at the name or path when they are not already known. Note that I am
> opening a text file and there is no corresponding window whose name I
> can
> peruse. Also, the file chosen by the user can be in an arbitrary
> location.
>
> Thanks.
>
> Bill Christens-Barry
>