Re: Apply "Substract background" to all files in subfolders

Posted by Wayne Rasband on
URL: http://imagej.273.s1.nabble.com/Apply-Substract-background-to-all-files-in-subfolders-tp3705174p3705186.html

> It stops when it finds a file which is not an image in a
> subdirectory  and  displays an appropriate error message
> (I have some ZIP files in  subdirectories).
> Can I modify the macro in order to just let it handle .tiff and
> .tif files for example?

You can modify the macro at
"http://rsb.info.nih.gov/ij/macros/BatchProcessFolders.txt" to handle
only .tif files by modifying the processFile() function as follows:

   function processFile(path) {
        if (endsWith(path, ".tif")) {
            open(path);
            run("Subtract Background...", "rolling=50 white");
            save(path);
            close();
       }
   }

The save() function appears to not work with files that have a ".tiff"
extension. You can use saveAs("tiff", path) but it changes the
extension from ".tiff" to ".tif".

-wayne