GetFileList ("C:/Directory/") : "C:/Directory" not taken into account ("file is not in a support format, a reader plugin is not available, or it was not found

Hello everyone,

I’m a debutant with ImageJ and I had a problem with this short macro :

liste = getFileList("C:/BAM/");
for ( i=0; i<liste.length; i++)
if ( endsWith(liste[i],".jpg") ) {
open( liste[i] );
run("Size...", "width=640 height=728 depth=1 average interpolation=Bilinear");
run("Set Scale...", "distance=640 known=3600 unit=µm ");
run("Scale Bar...", "width=500 height=4 font=14 color=White background=None location=[Lower Right] bold overlay");
saveAs( "jpeg", "C:/BAM/"+File.nameWithoutExtension+"Redim.jpg" );

in fact when I run it, nothing happens and this window appears :

And as you can see, imageJ is trying to open the last directory opened manually (BAM2 and not BAM) so without taking into account the lineliste=getFileList("C:/BAM/"). I solved the problem by adding at the beginning of the macro

dir = getDirectory("Choose a Directory ");

and it works but the variable stored in “dir” by this way is still (“C:/BAM”) so I don’t understand why the more complicated solution (to ask image J to open a dialog box to let the user chose the right directory) works but not the easiest one (type the right directory directly in the macro).

Is anyone can explain me this subtlety ?

Thank you in advance,


I suspect your problem is due to the way you entered the file/folder separator. I would try to replace the file separator with //, i.e. try “C://BAM//” instead of “C:/BAM/”.

For determining what the issue is exactly, could you replace this line:

open( liste[i] );

by these two?

print( liste[i] );
open( liste[i] );

It will then print out the filename it wants to open to the log window. You can then see in different scenarios what works and what doesn’t.


Thank you Volko.
I tried “//” instead of “/” but the issue persists (I aslo tried “\”).

Thank you Robert.
I tried what you suggest and I have the same information given by the error dialog box. In fact it displays the name of one of the file (ex “file10.jpg”) found in the directory specified (here “C:/BAM/” in the macro). So it means that ImageJ has correctly read “C:\BAM” as it is written but as you can see below it displays “F:/file10.jpg”.


In fact F:/ is my USB key I already accessed with imageJ before. But before launching the macro with “C:/BAM” repertory I closed imageJ and reopened it to be sure that it forgot the history of opening files.
And it seems that there is no effect.

It’s really curious to me because ImageJ remenbered a repertory I already accessed before closing it, and in the same time it reads the correct directory (C:/BAM) written in the macro (because it finds the file in it) but after it seems that it tried to open it in a different repertory (F:/).

Is it possible that it may be something wrong with the Java Virtual Machine which requires to initialize a variable corresponding to the directory before using it ? And so one of the way to do it is to use getDirectory() function ?


1 Like

It tries to open “file10.jpg” but there is no folder specified where this file is supposed to be. Try this:

open(directory + "/" + filename);

got it ! In fact I should have written open(directory + "/" + liste[i]) and not only open(liste[i])
Thank you Robert, you showed me the right way.

1 Like