Re: get directory of text window?
Posted by
Rasband, Wayne (NIH/NIMH) [E] on
URL: http://imagej.273.s1.nabble.com/get-directory-of-text-window-tp5013632p5013636.html
> On Jul 18, 2015, at 3:12 PM, Cammer, Michael <
[hidden email]> wrote:
>
> I am writing a macro where the user is prompted to open a file with tab delimited text in it. The command
>
> open();
>
> works fine and the command
>
> lines = split(getInfo("window.contents"),'\n');
>
> works perfectly too.
>
> Question:
>
> How can we get the directory that this open command operated on? We want to save the results in the same directory as the text file.
The File.directory macro function returns the directory path of the last file opened using a file open dialog and you can read the contents of a file without displaying it by using the File.openAsString(“") function. Here is an example:
str = File.openAsString("");
lines = split(str,"\n");
dir = File.directory;
-wayne
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html