// Recursively lists the files in a user-specified directory
// With ImageJ 1.37i or later, open files on the list by
// double clicking on them. A preview of 1.37i is available at
//   http://rsb.info.nih.gov/ij/ij.jar

  requires("1.32f");
  dir = getDirectory("Choose a Directory ");
  count = 1;
  listFiles(dir); 

  function listFiles(dir) {
      list = getFileList(dir);
      for (i=0; i<list.length; i++) {
          if (endsWith(list[i], "/"))
              listFiles(""+dir+list[i]);
          else
              print((count++) + ": " + dir + list[i]);
      }
  }
