Zotero 7: PDF file not renaming in UI
When you have an existing item in Zotero and then drag a PDF onto it, the PDF name doesn't change. The PDF name in the UI also doesn't change when you explicitly do a "Rename from parent metadata" from the menu.
It appears as though it's just a UI thing as the physical file has changed name (see attached image)
https://s3.amazonaws.com/zotero.org/images/forums/u5869622/kczh7giozr3yqo4lsoyi.png
It appears as though it's just a UI thing as the physical file has changed name (see attached image)
https://s3.amazonaws.com/zotero.org/images/forums/u5869622/kczh7giozr3yqo4lsoyi.png
Is there a way to update previous attachment titles to make things consistent (or would this be "dangerous")?
var items = ZoteroPane.getSelectedItems();
for (let item of items) {
if (!item.isRegularItem()) continue;
let attachment = await item.getBestAttachment();
if (!attachment) continue;
let title = attachment.getField('title');
if (title.endsWith('.pdf')) {
attachment.setField('title', 'PDF');
await attachment.saveTx();
}
}
This will go through the primary attachment of every selected item and convert the title of any that ends in ".pdf" to just "PDF".
You can test with a smaller number of selected items first to make sure it's doing what you expect.