Copy whole directory (folders and subfolders) and auto-assign new name

Hello!

I hope that this vibrant community can help me make my processing faster and easier.

I am currently working on a bigger project (Automatisation: Particle-count from non-leveled images).

Within this project I came across the following idea/task:

Can I copy a whole directory, and assign each folder a new name?
The reason is this: 3 cropped dublicates from each original sample will get created with another macro. These cropped samples are the same file type as the original samples. Thats why I need to save them somewhere else. Later the cropped samples are to be analyzed with a further makro (also batch process)

In detail the output should like this:

INPUT DIRECTORY
…/DATA/2102_FRM parent-folder
…/DATA/2102_FRM/KW sub-folder

run macro"COPY_DIRECTORY"

OUTPUT DIRECTORY
…/DATA/2102_FRM_cropped new parent-folder
…/DATA/2102_FRM_cropped/KW_cropped new sub-folder

I have looked at the Batch Process template and came up with this code:


// @File(label = "Input directory", style = "directory") input

// MAKRO: COPY_DIRECTORY
// GOAL: Copy the directory (folders and subfolders) and give each copied folder a new name


function processFolder(input) {
	list = getFileList(input);
	for (i = 0; i < list.length; i++) {
		if(File.isDirectory(input + list[i]))
			processFolder("" + input + list[i]);
			output_crop = input + "/_cropped/";
			File.makeDirectory(output_crop);
		}
}