@@ -0,0 +1,2794 @@
+//%0A// Mass_Importer.java%0A//%0A%0Aimport ij.IJ;%0Aimport ij.gui.YesNoCancelDialog;%0Aimport ij.io.DirectoryChooser;%0Aimport ij.plugin.PlugIn;%0Aimport java.io.File;%0Aimport java.util.HashSet;%0Aimport java.util.Vector;%0Aimport loci.formats.FilePattern;%0Aimport loci.formats.ImageReader;%0Aimport loci.plugins.LociImporter;%0A%0A/**%0A * Processes all image files in the chosen directory,%0A * grouping files with similar names.%0A *%0A * @author Curtis Rueden ctrueden at wisc.edu%0A */%0Apublic class Mass_Importer implements PlugIn %7B%0A%0A  public void run(String arg) %7B%0A    // prompt user for directory to process%0A    DirectoryChooser dc = new DirectoryChooser(%22Bio-Formats Mass Importer%22);%0A    String dirPath = dc.getDirectory();%0A%0A    // create a list of files we have already processed%0A    HashSet done = new HashSet();%0A%0A    // image reader object, for testing whether a file is in a supported format%0A    ImageReader tester = new ImageReader();%0A%0A    // list of files to actually open with Bio-Formats Importer%0A    Vector filesToOpen = new Vector();%0A%0A    // process all files in the chosen directory%0A    File dir = new File(dirPath);%0A    File%5B%5D files = dir.listFiles();%0A    IJ.showStatus(%22Scanning directory%22);%0A    for (int i=0; i%3Cfiles.length; i++) %7B%0A      String id = files%5Bi%5D.getAbsolutePath();%0A      IJ.showProgress((double) i / files.length);%0A%0A      // skip files that have already been processed%0A      if (done.contains(id)) continue;%0A%0A      // skip unsupported files%0A      if (!tester.isThisType(id, false)) continue;%0A%0A      // use FilePattern to group files with similar names%0A      String name = files%5Bi%5D.getName();%0A      FilePattern fp = new FilePattern(name, dirPath);%0A%0A      // get a list of all files part of this group, and mark them as done%0A      String%5B%5D used = fp.getFiles();%0A      for (int j=0; j%3Cused.length; j++) done.add(used%5Bj%5D);%0A%0A      filesToOpen.add(id);%0A    %7D%0A    IJ.showProgress(1.0);%0A    IJ.showStatus(%22%22);%0A%0A    // confirm that user wants to proceed in opening the file groups%0A    int numToOpen = filesToOpen.size();%0A    if (numToOpen == 0) %7B%0A      IJ.showMessage(%22No file groups found.%22);%0A      return;%0A    %7D%0A    String groups = numToOpen == 1 ?%0A      %221 file group%22 : (numToOpen + %22 file groups%22);%0A    YesNoCancelDialog confirm = new YesNoCancelDialog(IJ.getInstance(),%0A      %22Bio-Formats Mass Importer%22, %22Found %22 + groups + %22 in directory '%22 +%0A      dirPath + %22'; proceed?%22);%0A    if (!confirm.yesPressed()) return;%0A%0A    // launch the Bio-Formats Importer plugin to open each group of files%0A    for (int i=0; i%3CnumToOpen; i++) %7B%0A      String id = (String) filesToOpen.get(i);%0A      String params =%0A        %22location=%5BLocal machine%5D %22 +%0A        %22windowless=true %22 +%0A        %22group_files=true %22 +%0A        %22open=%5B%22 + id + %22%5D %22;%0A      new LociImporter().run(params);%0A    %7D%0A    IJ.showStatus(%22%22);%0A  %7D%0A%0A%7D%0A

Add "Bio-Formats Mass Importer" example plugin.