Batch convert/save as one file format to TIFF?

Hello all,

I hope someone will be able to help me with my question.

For my work I have 986 files that are in the .oir (Olympus) format. Our institute got the chance to play around with a new Olympus confocal and I do not have access to their software. Eager to see how my images came out, I installed the Olympus plugin on ImageJ (technically I am running FIJI, version 1.51g) and was able to open the files and play around with them.

Now I want to stitch the files (as all 986 images are of one single sample) and it comes out really nicely with the ImageJ plugins when I did a test stitch with a few of the files. However, I have to convert the files from .oir to TIFF before I can do any stitching and I do so via the ‘save as’ feature.

Basically what I do is:

-Open ImageJ
-Plugins --> Olympus viewer --> DragDrop
-I then Drag/Drop some .oir files in DragDrop box
-File --> Save as --> TIFF
-Once in TIFF format I go ahead with the stitch plugins

As it is a bit of a cumbersome procedure, is there anyway that I can ‘mass save’ or ‘mass convert’ or ‘batch save’ or ‘batch convert’ all of these .oir files in one go to TIFF files? Is there a macro feature or special button somewhere in ImageJ that I can press that will assist with the above procedure? Once converted it will take a few buttons to then set up the stitching procedure and get myself what I hope will be a really nice image.

Alternatively is there a stitch plugin with ImageJ that can stitch alternative file formats?

I feel this feature will be useful for other file formats as well, in addition to .oir, such as Zeiss or Nikon or Leica file formats.

Thank you for your help.

Dear @Gorion,

welcome to the forum!

There is a post by @ctrueden in another thread that might be helpful for you. Especially the Process_Folder.ijm macro. You can replace lines 28 and 29 with the loading mechanism of the Olympus plugin as recorded by the Plugins > Macros > Record command. For more information take a look at the Introduction to Macro Programming page of the ImageJ wiki.



The page is intended to be the central resource describing how to do these sorts of things.


Thank you both for your helpful reply. I had an attempt at using the macro creater to create what I had in mind but I didn’t have much luck. I will keep playing around with it and see if I can get it to work. Thank you again. :slight_smile:

1 Like

although the thread is already a bit dated I add my solution below as so far I could not find a solution in the forum or the cited locations. The difficulty was to properly open the .oir file which spans over multiple physical files. The Olympus plugin “Drag and drop” did that but the macro recorder did not unveil the details. So after inspection of the plugin jar I came up with the following based on the batch processing examples (you may simply ignore the string manipulation for the output destination).

# @File(label = "Input directory", style = "directory") srcFile
# @File(label = "Output directory", style = "directory") dstFile
# @String(label = "File extension", value=".oir") ext
# @String(label = "File name contains", value = "") containString

import os
import re
from ij import IJ, ImagePlus

sphRex = re.compile("(G\\d+)")

def run():
  srcDir = srcFile.getAbsolutePath()
  dstDir = dstFile.getAbsolutePath()
  for root, directories, filenames in os.walk(srcDir):
    for filename in filenames:
      # Check for file extension
      if not filename.endswith(ext):
      # Check for file name pattern
      if containString not in filename:
      process(srcDir, dstDir, root, filename)
def process(srcDir, dstDir, currentDir, fileName):
    spheroid = ""
    m =
    if (m):
        spheroid =
        IJ.log("Unknown file name type: " + fileName)

    outDir = os.path.join(dstDir, spheroid)
    # Saving the image
    if not os.path.exists(outDir):
    IJ.log("Saving to " + outDir)

    # Opening the image
    inFile = os.path.join(srcDir, fileName)
    IJ.log("Open image file " + inFile)
    IJ.runPlugIn("_Viewer", inFile)

    # Save as TIFF sequence
    oCmd = "format=TIFF name=" + spheroid + " save=[" + outDir + "\\]"
    IJ.log("Save: " + oCmd)"Image Sequence... ", oCmd)"Close")


Thank you Gucki. I admit I didn’t have much luck after spending some time with it and so I left the macro aside for the time being. With this possible solution I will have a go at it and see how far I go. Thank you again for your contribution.

Thanks Gucki! I’m not so clear how to run your code. I’ve tried run as macros or plugin in fiji but it has errors starting at the “import os”. I’m not so good at the coding field yet, so can you give some instruction?


from your error messages I assume that Fiji does not recognize it as a python macro. Just give the following a try: save the code in a file with extension .py (e.g. Then drag & drop that file onto Fiji. The macro editor should open with the macro and it should be fine to run.
You can check (in the editor) under the menu “Language” that Python is enabled and not “IJ1 Macro”.

Hope this helps,

Thank you! I combined the olympus viewer with the macro recording and batch processing. It worked somehow. But I’ll try your code again as well.