# Confused about GetTitle() and getDirectory() in ImageJ

Hi, I am confused about why when I run my macros It is always asking me for a directory. Can someone clarify how this works? Sorry if this is really basic.

I am trying to do macro to all the images in a folder. For each image I set global variables for the filename and the pathway by using
var filename = getTitle();
var ImageDirectory = getDirectory(filename);

How come when I run the macros on an image, it gives me a dialog to choose a folder? Then I have to choose the folder where the image is located for every image in that folder. Then the macro seems to process correctly. But I feel like I am missing something. Why do I have to choose the folder every time the macros opens a new image?

https://imagej.nih.gov/ij/developer/macro/functions.html#getDirectory
That is what getDirectory does. It creates a dialog. You want to create a file path, possibly as a string. There should be examples on the forum.