Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
kb:attachment_title_vs_filename [2024/11/30 07:44] – dstillman | kb:attachment_title_vs_filename [2025/04/21 01:45] (current) – dstillman | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Why do attachments have names like “PDF” or “Accepted Version” instead of their filenames in the items list? ====== | ||
+ | Attachments have two separate names: the attachment title shown in the items list and the filename of the file on disk. | ||
+ | |||
+ | Zotero automatically renames files on disk based on parent item metadata such as the title and authors. Since the parent item row in the items list already displays that metadata, Zotero doesn' | ||
+ | |||
+ | Subsequent files added to an item from the filesystem will still get titles named after the filename (without the file extension), since those are likely to be supplementary files and the filename may be informative. | ||
+ | |||
+ | You can view and change the title and filename by clicking on the attachment and looking in the item pane. | ||
+ | |||
+ | ==== Changes in Zotero 7 ==== | ||
+ | |||
+ | Zotero has always automatically renamed files on disk, and it has always used separate, simpler titles such as " | ||
+ | |||
+ | Zotero 7 changes attachment-title handling in a couple particular cases: | ||
+ | |||
+ | - Prior to Zotero 7, if you **manually** ran Rename File from Parent Metadata, the attachment title was changed to the filename. This was a bug that led many people to believe that files weren' | ||
+ | - When dragging a file from the filesystem or creating a parent item, Zotero now sets the title of the first attachment of a given type to " | ||
+ | |||
+ | People who were unnecessarily running Rename File from Parent Metadata on every attachment or who were using the ZotFile plugin (which also set the title to the filename) might be used to seeing filenames in the items list, but we'd encourage people to give the new behavior a try. | ||
+ | |||
+ | === Updating Titles Changed Before Zotero 7 === | ||
+ | |||
+ | If you'd like to convert attachments previously changed to match the filename to use simpler " | ||
+ | |||
+ | <code javascript> | ||
+ | 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(' | ||
+ | if (title.endsWith(' | ||
+ | attachment.setField(' | ||
+ | await attachment.saveTx(); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | This will go through the primary attachment of every selected item and convert the title of any that ends in " | ||
+ | |||
+ | You should test with a smaller number of selected items first to make sure it's doing what you expect. |