Batch mode stops after first file in folder

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Batch mode stops after first file in folder

CBIer
Hello everybody,

I have a small problem. I have a set of files in folder 1, and I want to process them all and save the results in as an excel file in folder 2.
My macro works, but it only porecesses the first file and then it stops. What am I missing in my code?

Right now my Macro is:

dir1 = getDirectory("Choose a Directory" );
dir2 = getDirectory("Choose a Directory");
setBatchMode(true);
list = getFileList(dir1);
for (i=0; i<list.length; i++) {
showProgress(i+1, list.length);
open(dir1+list[i]);

setAutoThreshold("RenyiEntropy dark");
//run("Threshold...");
setThreshold(15, 255);
run("Convert to Mask");
run("Particles8 ", "white exclude label morphology show=Particles filter minimum=500 maximum=9999999 display overwrite redirect=None");

name = getTitle;
index = lastIndexOf(name, ".");
if (index!=-1) name = substring(name, 0, index);
name = name + ".xls";
saveAs("Results", dir2+name);
print(dir2+name);
close();

I hope somebody can help me, I am kind of a newby with ImageJ at the moment.
Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Batch mode stops after first file in folder

Krs5
Hi there,

Without going through the whole code after the if-statement you open with a { but you did not close the end of the code to be executed within the if-statement with a }. Looks like this should be at the end of your code.

Best wishes

Kees


Dr Ir K.R. Straatman
Senior Experimental Officer
Centre for Core Biotechnology Services
University of Leicester

http://www.le.ac.uk/biochem/microscopy/home.html




-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of CBIer
Sent: 28 January 2013 13:42
To: [hidden email]
Subject: Batch mode stops after first file in folder

Hello everybody,

I have a small problem. I have a set of files in folder 1, and I want to process them all and save the results in as an excel file in folder 2.
My macro works, but it only porecesses the first file and then it stops.
What am I missing in my code?

Right now my Macro is:

dir1 = getDirectory("Choose a Directory" );
dir2 = getDirectory("Choose a Directory"); setBatchMode(true); list = getFileList(dir1); for (i=0; i<list.length; i++) { showProgress(i+1, list.length); open(dir1+list[i]);

setAutoThreshold("RenyiEntropy dark");
//run("Threshold...");
setThreshold(15, 255);
run("Convert to Mask");
run("Particles8 ", "white exclude label morphology show=Particles filter
minimum=500 maximum=9999999 display overwrite redirect=None");

name = getTitle;
index = lastIndexOf(name, ".");
if (index!=-1) name = substring(name, 0, index); name = name + ".xls"; saveAs("Results", dir2+name); print(dir2+name); close();

I hope somebody can help me, I am kind of a newby with ImageJ at the moment.
Thanks!



--
View this message in context: http://imagej.1557.n6.nabble.com/Batch-mode-stops-after-first-file-in-folder-tp5001568.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Batch mode stops after first file in folder

CBIer
I placed the missing }. It was a small mistake, but now the macro works perfectly.
Thanks a lot!