More efficient way to duplicating images



I have a directory full of many images and I would like to copy them all to a different directory. Right now I have a script that opens each image and saves it in a new directory, which worked fine when I was testing it with smaller groups of images, however now that I am working with more images, this seems to take a while and I suspect there is a more efficient way of doing this. This is the current code I have:

function dupFile(input, fileToDup) {
run("Bio-Formats Importer", "open=[" + input + "/" + fileToDup + "] autoscale color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");
saveAs("tiff", input + "/" + dupDir + "/" + fileToDup);|

Does anyone have any suggestions to speed up the code?



There was a great hint by @oburri last week using the exec() command. With it, you can run a native command (which is obviously going to make it platform specific), but it might offer some useful functionality.

Check out the macro language reference or the ExecExamples script.


You could try this macro function: File.copy(path1, path2); // Copies a file.

For more File.xxxx functions, see: