From what I can tell, I’ve followed the documentation exactly on how this should be done. Here’s an example from the Adobe documentation:
const newFile = await folder.createFile("examples.txt", { overwrite: true });
newFile.write("Hello, world!");
And here’s how I’ve written it in my code:
async function saveDocumentAsJPEGToFolder(current_image) {
// note: users are only prompted once to use the folder-picker, at the start of each batch operation. the below happens in the background.
const entry = await output_folder_to_use.createFile(`${app.activeDocument.title}_${current_image.name}.jpeg`, { overwrite: true });
const outputFileToken = await fs.createSessionToken(entry);
const save_image_as_JPEG = {
_obj: "save",
as: {
_obj: "JPEG",
extendedQuality: image_save_quality,
matteColor: {
_enum: "matteColor",
_value: "none",
},
},
copy: true,
in: {
_path: outputFileToken,
_kind: "local"
}
};
try {
result = await app.batchPlay([save_image_as_JPEG]);
} catch (error) {
console.error(`Error during image save`, error);
}
}
However when there are images with identical names already saved into this folder? It does NOT overwrite them with the new images. Instead, the old images remain in there, and the new ones that should overwrite them never get saved into there.
Any clue why this is happening? Have I written something wrong in the code, or is there some additional parameter I need to specify in the batchPlay code to ensure the overwrite event occurs properly?
Thanks!