macro "Merge_Channel" { path = getDirectory("Choose a Directory to process"); list = getFileList(path); for (i = 0; i < list.length; i++) { greenIndex = endsWith(list[i], "2.jpg"); // Green if (greenIndex == 1) { open(list[i]); // open green greenImg = getTitle(); open(list[i+1]); // open red redImg = getTitle(); merge_Channel(greenImg,redImg); } }