print("dir2 is "+dir2); immediately after the
getDirectory() call @susan-sheehan suggests. It should contain the path and that should be shown in your log window.
I notice that you ask quite a few questions on macro programming (syntax). If you are learning to program macros, you may consider using ImageJ1 for a while, as it has a Debug facility that ImageJ2 (FIJI) is missing (effectively).
In ImageJ1 you can inspect your variables at every step your code makes,you can hop skip and jump over lengths of codes by clever use of the if() then debug() construction and do many more handy things to see what is going on (inspecting array contents comes to mind). Once a macro is operational, you can move to FIJI if that is necessary for some extended feature FIJI has, and ImageJ1 hasn’t.