|
Dear List,
I have a macro that batch processes all images from a specified source directory and then saves the results as a text file to a specified destination directory.
The name for the results file consists of the source directory with the prefix "IJ results_",
i.e. if the macro processes all images from the folder "test data" then the results file will be called "IJ results_test data.txt".
I now wanted to add a step to make sure the filename doesn't exist before saving and, in that case, overwriting.
Unfortunately, the File.exists command returns false when it should return true (e.g. when for the sake of testing I run the macro twice on the same data set).
I am not sure if I am using the File.exists command correctly.
Here are the relevant parts of my macro:
dir1 = getDirectory("Choose Source Directory ");
foldername=File.getName(dir1);
dir2 = getDirectory("Choose Destination Directory");
//processing steps; relevant results are printed to log file
if (File.exists(dir2+"IJ results_"+foldername))
{Dialog.create("file exists. overwrite?");
Dialog.show();}
selectWindow("Log");
saveAs("text", dir2+"IJ results_"+foldername);
Can anybody tell me how to correctly use the File.exists command?
Many thanks,
Carlos
|