getFileList in macros

I am trying to run a macro. Its runs fine but the moment I add getFileList to get a list of the files in the folder, I get the following error:

TypeError: [JavaClass ij.IJ] has no such function “getFileList” in at line number 2

As far as I see there is nothing wrong witht this as this is a documented method. Am I missing some configuration?

Dear @rupinder10,

if you take a look at the Java class ij.IJ you will not find a getFileList() method.

That makes me wonder if you are indeed trying to a run an ImageJ macro or a script in another supported language?


I found the same problem too. But then all the samples use getFileList() everywhere. So there is obviously some way to do this but I am missing some configuration. Or maybe this has been replaced with some other call. I have tried Javascript and the same problem there too.

This is an example of how getFileList() works for me:

  1. Open Fiji
  2. Create a new script (File > New > Script…)
  3. Set language to ImageJ Macro (Language > ImageJ Macro)
  4. Run the following script that let’s you select a directory and prints the name of the first file from that directory:
directory = getDirectory("Test directory");
files = getFileList(directory);

Does this work for you @rupinder10?

1 Like