-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0_Template_for_Recursive_Processing_and_Analysis.ijm
executable file
·53 lines (43 loc) · 1.52 KB
/
0_Template_for_Recursive_Processing_and_Analysis.ijm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
s=File.separator;
Dialog.create("Recursive Batch Processing Template");
Dialog.addCheckbox("Input Directory = Output Directory", true);
Dialog.addMessage("Recursive Batch Processing of files that end with:");
items=newArray("_C2_Reg", "_C2toC1_Reg_C2_Spl");
Dialog.addString("Specify input Identifier:", ".tif");
Dialog.addMessage("Label outputfiles with:");
Dialog.addString("Specify output Identifier:", "_new.tif");
Dialog.show();
inDisOutD=Dialog.getCheckbox();
RecBatchProc=Dialog.getChoice();
InIdentifier=Dialog.getString();
OutIdentifier=Dialog.getString();
inDir=getDirectory("Choose the Raw Data Containing Folder");
if (inDisOutD==true) {
outDir=inDir;
}
else {
outDir=getDirectory("Choose Output Folder");
if ((inDir==outDir) || (startsWith(outDir, inDir))) {
exit("Input folder must be different from and not within output folder!");
}
}
//setBatchMode(true);
if (RecBatchProc==true) {
RecursiveBatchProcessing(inDir, outDir);
}
//setBatchMode(false);
function RecursiveBatchProcessing(inDir, outDir) {
list = getFileList(inDir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/")) {
RecursiveBatchProcessing(inDir+list[i], outDir+list[i]);
}
else if ((endsWith(list[i], InIdentifier))&&(!File.exists(replace(outDir+s+list[i], InIdentifier, OutIdentifier)))) {
//Enter your custon processing steps here.
//Use macro recorder to record your custom workflow.
//Also, do not forget do adapt file saving.
saveAs("tiff", replace(outDir+s+list[i], InIdentifier, OutIdentifier));
}
}
}
print("Done");