@@ -0,0 +1,1438 @@
+# @File(label = %22Input directory%22, style = %22directory%22) srcFile%0A# @File(label = %22Output directory%22, style = %22directory%22) dstFile%0A# @String(label = %22File extension%22, value=%22.tif%22) ext%0A# @String(label = %22File name contains%22, value = %22%22) containString%0A# @boolean(label = %22Keep directory structure when saving%22, value = true) keepDirectories%0A%0A# Compare with the original Process_Folder to see how ImageJ 1.x%0A# GenericDialog use can be converted to @Parameters.%0A%0Aimport os%0Afrom ij import IJ, ImagePlus%0A%0Adef run():%0A  srcDir = srcFile.getAbsolutePath()%0A  dstDir = dstFile.getAbsolutePath()%0A  for root, directories, filenames in os.walk(srcDir):%0A    for filename in filenames:%0A      # Check for file extension%0A      if not filename.endswith(ext):%0A        continue%0A      # Check for file name pattern%0A      if containString not in filename:%0A        continue%0A      process(srcDir, dstDir, root, filename, keepDirectories)%0A %0Adef process(srcDir, dstDir, currentDir, fileName, keepDirectories):%0A  print %22Processing:%22%0A   %0A  # Opening the image%0A  print %22Open image file%22, fileName%0A  imp = IJ.openImage(os.path.join(currentDir, fileName))%0A   %0A  # Put your processing commands here!%0A   %0A  # Saving the image%0A  saveDir = currentDir.replace(srcDir, dstDir) if keepDirectories else dstDir%0A  if not os.path.exists(saveDir):%0A    os.makedirs(saveDir)%0A  print %22Saving to%22, saveDir%0A  IJ.saveAs(imp, %22Tiff%22, os.path.join(saveDir, fileName));%0A  imp.close()%0A %0Arun()%0A

Add Process_Folder_IJ2 template