find distinct subfolder
Posted by
Tom Pot on
Jun 11, 2015; 6:42am
URL: http://imagej.273.s1.nabble.com/find-distinct-subfolder-tp5013112.html
Hi together,
I have a macro that loops through folders and subfolders to process images. The problem I encountered is that the macro should only process the images in a subfolder named e.g. test_folder. Afterwards it should screen the next folder and subfolders for the next 'test_folder'.
I use the following code to loop through folders and subfolders:
dir = getDirectory("Select Subjects Directory");
setBatchMode(true);
count = 0;
countFiles(dir);
n = 0;
processFiles(dir);
//print(count+" files processed");
function countFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
countFiles(""+dir+list[i]);
else
count++;
}
}
function processFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
processFiles(""+dir+list[i]);
isDirectory(newdir);
else {
showProgress(n++, count);
path = dir+list[i];
calculate_first(path); // process function 1
calculate_second(path); // process function 2
}
}
}
Does anybody has an idea how to search a distinct subfolder within my subjects dir ?
I´m very thankful for any suggestions,
Thomas
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html