On rename event, the callback will ignore to rename the attachment filename if the the attachment folder was already exists
const exitsDst = await this.app.vault.adapter.exists(stripedNewAttachPath);
if (exitsDst) {
// if the file exists in the vault
if (eventType === RENAME_EVENT_TYPE_FILE) {
new Notice(`Same file name exists: ${stripedNewAttachPath}`);
return;
} else if (eventType === RENAME_EVENT_TYPE_FOLDER) {
// for most case, this should not be happen, just notice it.
new Notice(`Folder already exists: ${stripedNewAttachPath}`);
return;
}
} else {
const cfile = this.app.vault.getAbstractFileByPath(stripedOldAttachPath);
if (cfile === null) {
return;
}
await this.app.fileManager.renameFile(cfile, stripedNewAttachPath);
}
On rename event, the callback will ignore to rename the attachment filename if the the attachment folder was already exists