Problem with custom batch processing macro

Hello all,

I’ve used the “Record” function of fiji alongside the macro creation functionality to try and make a macro to batch process some .avi files located together in one folder. fiji auto-generated the code to open and sort the files in the folder, and I am able to open each file individually myself by clicking and dragging. Weirdly when I run my macro I get the error message “file is not in a supported format, a reader plugin is not available or it was not found”. I’m sure this isnt the only issue in my code, but its preventing me from progressing to the next (probable) issue.

I’ve attached my code below, any help would be greatly appreciated:

#@ File (label = “Input directory”, style = “directory”) input
#@ File (label = “Output directory”, style = “directory”) output
#@ String (label = “File suffix”, value = “.tif”) suffix

// See also for a version of this code
// in the Python scripting language.


// function to scan folders/subfolders/files to find files with correct suffix
function processFolder(input) {
list = getFileList(input);
list = Array.sort(list);
for (i = 0; i < list.length; i++) {
if(File.isDirectory(input + File.separator + list[i]))
processFolder(input + File.separator + list[i]);
if(endsWith(list[i], suffix))
processFile(input, output, list[i]);

function processFile(input, output, file) {
// Do the processing here by adding your own code.
// Leave the print statements until things work, then remove them.
print(input + file);
open(input + file);
title = getTitle();

run("Slice Remover", "first=1 last=4 increment=1");
makeRectangle(172, 16, 565, 537);
run("Deinterleave", "how=2");
selectWindow((title+" #1");
run("Z Project...", "projection=[Average Intensity]");
selectWindow((title+" #2");
run("Z Project...", "projection=[Average Intensity]");
imageCalculator("Subtract create stack", "contra_10s_1Hz_2_2019-11-13-144041-0000.avi #1","AVG_contra_10s_1Hz_2_2019-11-13-144041-0000.avi #1");
selectWindow("Result of contra_10s_1Hz_2_2019-11-13-144041-0000.avi #1");
selectWindow("AVG_contra_10s_1Hz_2_2019-11-13-144041-0000.avi #2");
imageCalculator("Subtract create stack", "contra_10s_1Hz_2_2019-11-13-144041-0000.avi #2","AVG_contra_10s_1Hz_2_2019-11-13-144041-0000.avi #2");
selectWindow("Result of contra_10s_1Hz_2_2019-11-13-144041-0000.avi #2");
imageCalculator("Subtract create stack", "Result of contra_10s_1Hz_2_2019-11-13-144041-0000.avi #1","Result of contra_10s_1Hz_2_2019-11-13-144041-0000.avi #2");
selectWindow("Result of Result of contra_10s_1Hz_2_2019-11-13-144041-0000.avi #1");
setMinAndMax(0, 5);
saveAs("Tiff", "C:/Documents/Data/Mesoscope/JS20191113/Processed/processed_contra_10s_1Hz_2_2019-11-13-144041-0000.tif");
print("Processing: " + input + File.separator + file);
print("Saving to: " + output);


I get the same error message when the path is not correct, so please make sure the path and filename are correct and do not contain any special characters.

If the open does not work you can also try:

run("AVI...", "open=["+input+file+"]");
run("Bio-Formats", "open=["+input+file+"] autoscale color_mode=Composite rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");

Best regards,

Dear Volker,

Thank you for getting back to me.
You were right, didn’t know to use / and not \ but its working now.

All the best,