How can I get the directory of a macro file?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I get the directory of a macro file?

bens0545
I want to copy my macro file into different folders, and have the macro
operate on the files in that folder. Currently I am typing the new directory
path into the macro, but I would like the macro to get the directory that it
is in automatically. How can I do this?

Thanks!



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: How can I get the directory of a macro file?

Wayne Rasband-2
> On May 8, 2018, at 11:27 PM, bens0545 <[hidden email]> wrote:
>
> I want to copy my macro file into different folders, and have the macro
> operate on the files in that folder. Currently I am typing the new directory
> path into the macro, but I would like the macro to get the directory that it
> is in automatically. How can I do this?

The File.directory() macro function returns the path to the directory that a macro was loaded from.

-wayne

> --
> Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: How can I get the directory of a macro file?

Straub, Volko A. (Dr.)
No need to copy the macro into a different folder to work on different sets of images. If you want to process files in a different folder, use the getDirectory(string) command to get the path to your files. Have a look at the documentation for the built-in macro functions (https://imagej.nih.gov/ij/developer/macro/functions.html#G) for further information and links to examples.
Hope this helps,
Volko

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Wayne Rasband
Sent: 09 May 2018 05:42
To: [hidden email]
Subject: Re: How can I get the directory of a macro file?

> On May 8, 2018, at 11:27 PM, bens0545 <[hidden email]> wrote:
>
> I want to copy my macro file into different folders, and have the
> macro operate on the files in that folder. Currently I am typing the
> new directory path into the macro, but I would like the macro to get
> the directory that it is in automatically. How can I do this?

The File.directory() macro function returns the path to the directory that a macro was loaded from.

-wayne

> --
> Sent from: http://imagej.1557.x6.nabble.com/

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

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