File Renaming - Batch rename filenames from parent metadata

Hi, I checked the discussion board and I didn't find an answer for my question.

In Zotero 7, if I change the 'Filename Format', how can I then apply these changes to my files/attachments? I cannot highlight them them since, the 'Rename from Parent Metadata' button is now only available for the attachments, not the library items, so I cannot even 'Ctrl+A'. I have over 4000 files (one file per item), how can I rename these? Is there a way and I am just missing something obvious?

Thanks for your work!
  • We're working on an improvement in this area. In a future version, you will be prompted after making a change whether to apply the new filename format to all files in your library.

    For now, as a workaround, you can do the following:

    1. Select Tools → Developer → Run JavaScript
    2. Check "Run as async function"
    3. Paste the following code:

    items = (await Zotero.Items.getAll(Zotero.Libraries.userLibraryID, false, true))
    .filter(i => i.isFileAttachment() && !!i.parentItem && Zotero.Attachments.isRenameAllowedForType(i.attachmentContentType))
    .map(i => i.itemID);
    ZoteroPane.selectItems(items);



    4. Press Run. Zotero might freeze for a second or two.
    5. Afterwards, in your main Zotero window, attachments that can be renamed should be selected, and you should be able to run "Rename from Parent Metadata" from the context menu of any of the selected items.
  • That is nice to hear. Thank you so much, I will try. And thanks for the fast response!
  • You can just also construct a search (quick search or advanced search) that matches only attachments (e.g., [Attachment File Type] [is] [PDF] in advanced search), do Ctrl-A to select search matches, press Enter if you're in an advanced search to select the items in the main window, and then right-click on the selection.
  • Thank you Dan, for this fast support. I have tried the last instruction via search-fields. However, at the very last step, the right-click on the selection does not help me. The search yields not only the pdf-files, but also the parent-items in the library. (I had to check the chebox to include the parent-items, otherwise the search finds nothing) Therefore Ctrl-A & Enter selects both those item-types , therefore the option to rename PDF-Files is not given by Zotero in the right-click-menu.
  • But the good news is: all the items are extended so going through the items and selectin the individual PDFs is actually quite fast for me (<100 items)
  • It depends on what exactly you need to search for. You can also use nested saved searches. But if constructing a search that matches just attachments is complicated, you can also use the code from @tnajdek above.
Sign In or Register to comment.