input=getDirectory("Input directory");output=getDirectory("Output directory");processFolder(input);functionprocessFolder(input){//-- get a list of files and folders in the inputlist=getFileList(input);//-- DEBUG only, print the list to see what we have//Array.print(list);//-- Iterate the listfor(i=0;i<list.length;i++){//-- If the item is a directory, list the contents of the directory and pull the first alphanumerically sorted filenameif(File.isDirectory(input+list[i])==1);{fileList=getFileList(input+list[i]);//-- Sort to get alphabeticalfileList=Array.sort(fileList);fileListFirst=fileList[0];}//-- DEBUG only, make sure the path looks good//print(input+list[i]+fileListFirst);//-- Open the image sequence by specifying the first image filename in the sequencerun("Image Sequence...","open=["+input+list[i]+fileListFirst+"] file=.tif sort");//-- Do what you dorun("Canvas Size...","width=5000 height=5000 position=Center");//-- Save the file as a tif stacksave(output+replace(list[i],"/","_")+replace(fileListFirst,".tif","_series.tif"));//-- Close the filesclose("*");}//-- folder loop}//-- close function
P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P