Assistance in creating a Batch Macro for Cell Counts

Thank you for taking your time to read this!

I’m trying to complete an undergraduate thesis studying the ways in which Eastern Oysters respond to Red Tide (Karenia brevis) Low-Toxin and High-Toxin. -A significant portion of this is performing cell counts to determine a reduction in cell count over time-

I have all of the image files I’ll be analyzing (~900), and I’ve been struggling to properly construct a macro to run a batch particle analysis. I’m extremely new to this realm and would appreciate any help whatsoever.

The basic flow of this macro is as follows
Set input & output directories -> open file -> change file type to 16-bit -> adjust file to black & white using adjust & applying default threshold -> using Analyze particles to generate a cell count -> saving the summary as an excel file and, ideally, compiling these cell counts into a single .xls file

\ Selecting basic input & output directories
dir1 = getDirectory("Choose Source Directory ");
dir2 = getDirectory("Choose Destination Directory ");
list = getFileList(dir1);

\ Enabling batch mode and setting list & i value lengths
setBatchMode(true);
for (i=0; i<list.length; i++) {
showProgress(i+1, list.length);

\ Opening the input file & starting the macro
open(dir1+list[i]);
{

\ Changing file type to 16-bit, then Black & White adjusting image with default Threshold
run(“16-bit”);
setAutoThreshold(“Default”);
//run(“Threshold…”);
setOption(“BlackBackground”, false);
run(“Convert to Mask”);
run(“Close”);

\ Performing Cell Count with “Analyze Particles” & Saving Summary in an output folder

run(“Analyze Particles…”, “size=2-Infinity circularity=0.20-1.00 show=Ellipses display summarize”);
saveAs(“Results”, “C:\Users\Danie\Desktop\Summary.xls”);
selectWindow(“10.jpg”);
selectWindow(“Drawing of (dir1+list[i]).jpg”);
close();
selectWindow("(dir1+list[i]).jpg");
close();
}