Is it possible to bulk rename file attachments?

I have the zotfile plugin setup to put PDF attachments in my ~/Documents/Papers folder on a Mac, and that is working just fine. However, for some reason I cannot remember, Zotero itself adds a digit at the very end of the filename (see the pasted image).

So the actual file name is ~/Documents/Papers/Abdelsalam-2013-A_comparison.pdf, but Zotero thinks it should be ~/Documents/Papers/Abdelsalam-2013-A_comparison2.pdf

That extra digit is not always a "2". Sometimes it is missing and sometimes it is a "3" or even a "4".

https://s3.amazonaws.com/zotero.org/images/forums/u14489236/z6m7k5qiieu5fuwcet0g.png

Is there any way within Zotero to bulk rename what it *thinks* the filename should be so that I can erase any numerical digit that might appear before the .pdf? I know how to do this in a directory from the command line, but I'm not sure how to change what Zotero thinks the name should be. I'd like to do this in a bulk way because I have about 1700 attachments and this is affecting about 90% of them.

I apologize if this is a "zotfile" question instead of a zotero question.
  • edited June 15, 2024
    Since linked PDFs are (most commonly) all stored in the same folder, they must have distinct names. So Zotfile (AFAIK) adds the '2' suffix if there is already a file of the same name in that folder (or higher numbered suffixes if there are more than two same-name files in the folder). It commonly occurs when you save several versions of a PDF to the same item, or when merging duplicates that each have a PDF (I always check merged duplicates for such redundancy). If you've subsequently deleted the linked PDF with no suffix from the item (eg with the delitem plugin), you might be left with just the '2' version in your linked file folder. There may be other scenarios that lead to the number suffix being auto-added to PDF file names, but I don't think I've seen any.

    So the first thing to check would be if there are in fact two PDF files with the same main name in your Zotfile Custom Location folder for these cases. If so, you would need to decide on which one to delete first, before you can remove the suffix from any '2' versions. But if there is then only one linked PDF for each item in your linked file folder, Zotfile's right-click Manage Attachments\Rename&Move should rename the single PDF without the '2' suffix. That operation can be applied to multiple files at once (although best to do them in smallish chunks).
Sign In or Register to comment.