Sort/Filter by File Size

Hello- I am a PhD student in biological sciences looking to write my literature review for my dissertation. Due to the limited amount of storage I can afford, I'd like to remove some of the larger PDF files from my Zotero library. Is there a way to sort or filter files so I can easily view which are the largest?

Thanks!
  • Hi. I'm interested too, but I couldn't find any way to do that. Any ideas?
  • edited May 25, 2023
    You would do a search in your OS (ie outside Zotero) for PDFs under the zotero\storage hierarchy, and then sort by size.

    If you want to keep some access to the bigger files from within Zotero, you could copy those files to another folder on your computer (eg cloud-mirrored folder) before moving them to the bin within Zotero (which will remove them from Zotero online storage when synced). Then use Add Attachment->Attach Link to File, so that Zotero can still find that file on that computer (in its new folder location). If you want to access them on another computer, you would have to copy them to the same path on that computer too (or use the Linked Attachment Base Directory setting if the path is different). For larger scale implementation of that linked file strategy, look at Zotfile.

    I feel for students (or others) who can't afford sufficient paid online storage for their study needs. I might note that in the days before programs with online syncing, access to the same PDF/file collection across computers was commonly achieved by keeping them on a small portable HDD (that was moved between computers), and pointing the software to that drive, to find them in the same way on each computer. Some people still use that approach for Zotero PDF file storage.
  • Is there a solution for this within Zotero?
  • edited May 15, 2024
    I can suggest a command line solution. Go to /Zotero/storage and, try this command (on Mac) or equivalent command:


    > find . -name '*.pdf' -exec du -k {} + | sort -nr | awk '{ $1=""; print substr($0,2) }'

    Print list with file size:


    > find . -name '*.pdf' -exec du -k {} + | sort -nr | awk '{ size=$1 "K"; $1=""; print size " " substr($0,2) }'

    You might need to use du -b option if you are using Linux.
  • This probably isn't an equivalent command, but here's a something similar in powershell. It needs to be run from the Zotero storage folder.

    ls -r *.pdf | Sort-Object -Property Length | Select -l 5

    Lists all the pdfs, sorts them by file size, and prints out the five largest pdfs with their paths. If you have other attachments (e.g., html archives or word documents), they won't be detected by this command, which exclusively accounts for PDFs.

    Admittedly, the "truer" PowerShell command would use Get-ChildItem, which is aliased by ls. (I don't really care, but here's to trying to preempt any terminally online fans of powershell).

    Get-ChildItem -r *.pdf | Sort-Object -Property Length | Select -l 5
Sign In or Register to comment.