Login  Register

Recusive operation on subfolders

Posted by Ludwig_Curie on Dec 18, 2007; 12:43pm
URL: http://imagej.273.s1.nabble.com/Recusive-operation-on-subfolders-tp3697711.html


Hello every one
 
I am sorry if my questions seems to be a bit silly, but I was not able to find any good solution for my problem.
 
What I whant to do is a simple image operation on several files with different names in different subfolders.
I am able to do it automatically but on only one folder, and I have to rename each file to fit the name in my macro which is not convenient at all.
 
This is the code I am using now :
 
dir1= getDirectory("Choose Destination Directory");
open(dir1+"rouge.tif");
open(dir1+"bleu.tif");
 
selectWindow("rouge.tif");
run("Multiply...")
saveAs("Tiff", dir1+"GFrouge.tif");
 
imageCalculator("Add create 32-bit", "bleu.tif","GFrouge.tif");
//run("Image Calculator...", "image1=bleu.tif operation=Add image2=rouge.tif create 32-bit");
saveAs("Tiff",dir1+"add.tif");
 
The structure of my directory and file is the following:
Folder A containing subfolders B,C,D,… Each sub folder contain only two images named XXX-NDD2.tif and XXX-NDD3.tif ( where XXX is different from one subfolder to the other)
 
What I want to do is the following : Select only the Folder A and allow imageJ going first to subdirectory B, read the name of the files and make the operation multiply XXX-NDD3.tif, save as GFXXX.tif in subfolder B then image calculator of adding GFXXX and  XXX-NDD2.tif  and save as : add-XXXX.tif still in subfolder B. Then do the same thing recursively for the other subdirectory.
 
Thank you for your help.
 
Ludwig