Login  Register

Re: batch processing across folders

Posted by G. Esteban Fernandez on Jan 22, 2009; 8:55pm
URL: http://imagej.273.s1.nabble.com/batch-processing-across-folders-tp3693993p3693994.html

Damon,

When you get a list of names inside a folder, subfolder names end with "/".
Thus, what I've done in the past to process subfolders is run a for loop to
parse through the list of names in a folder and for each name that ends with
"/" run another for loop to parse through the files in that subfolder.  The
code looks something like this:
mainDir = getDirectory("Choose a main directory ");
mainList = getFileList(mainDir);

for (i=0; i<mainList.length; i++) {  // for loop to parse through names in
main folder
     if(endsWith(mainList[i], "/")){   // if the name is a subfolder...

          subDir = mainDir + mainList[i];
          subList = getFileList(subDir);

           for (j=0; j<subList.length; j++) {  // for loop to parse through
names in subfolder

               // DO STUFF

          }
     }
}


Good luck!

-Esteban


On Thu, Jan 22, 2009 at 1:56 PM, Damon Poburko <[hidden email]>wrote:

> Hi All,
>  I have a some analysis that I would like to batch process. I have a macro
> that runs and saves my analysis for images in a given folder. What I would
> like to do is set up a parent macro, or expand the macro, to start in a
> user-defined parent folder, generate a list of subfolders and then apply the
> analysis to each of those subfolders.  I'm not sure if IJ's macro language
> will allow this , or if it  requires a proper  pluggin.
> Thanks,
> Damon
>
>
> --
>
> Damon Poburko, PhD
> Postdoctoral Research Fellow
> Stanford University School of Medicine
> Dept. of Molecular & Cellular Physiology
> 279 Campus Dr., Beckman B103, Stanford, CA 94305
> Ph: 650 725 7564, fax: 650 725 8021
>



--
G. Esteban Fernandez, Ph.D.
Associate Director
Molecular Cytology Core Facility
University of Missouri
120 Bond Life Sciences Center
Columbia, MO  65211

http://www.biotech.missouri.edu/mcc/

573-882-4895
573-884-9395 fax