Posted by
pang on
Apr 06, 2011; 1:07pm
URL: http://imagej.273.s1.nabble.com/Apply-to-all-files-tp3685140p3685144.html
Hi, I have following codes might help you. You may want to modify a
little bit to suit your need.
run("Set Measurements...", "area mean standard min integrated median
area_fraction stack limit display redirect=None decimal=3");
run("Clear Results");
dir1 = getDirectory("Choose Directory ");
list = getFileList(dir1);
setBatchMode(false);
for (i=0;i<list.length;i++) {
if (endsWith(list[i],"tif") || endsWith(list[i],"TIF")){
open(dir1+ list[i]);
run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel");
run("Measure");
close();
}
else if (endsWith(list[i],"/")) {
idx2=lengthOf(list[i])-1;
dir2=dir1+substring(list[i],0,idx2);
list2 = getFileList(dir2);
for (j=0;j<list2.length;j++) {
if (endsWith(list2[j],"tif") || endsWith(list2[j],"TIF")){
open(dir2+"\\"+ list2[j]);
run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel");
run("Measure");
close();
}
}
}
}
-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of
Wilson R S (AT)
Sent: Wednesday, April 06, 2011 9:02 AM
To:
[hidden email]
Subject: Apply to all files...
I am thinking someone would probably have already wrote this code/macro,
but can't find it...
I want to apply a macro to all files within a certain folder and all its
subfolders. I can see how this works in theory with
getFileList(Directory), but just can't seem to get the code quite rite.
Any help would be much appreciated.
Rhod