Advanced Search for Collection and File Type

Answering to questions in this thread
http://forums.zotero.org/discussion/8072/linked-attachments-two-requests/#Comment_66565
I'm trying to suggest a good way to export all the attached pdfs (and just those) in one collection.

I thought something like the solution we found here
http://forums.zotero.org/discussion/13536/rename-all-pdf-files-in-a-collection/#Item_2
would work perfectly:
Saved search for "Collection is XXX" and "Attachment file type is PDF"
In the saved search folder ctrl+a will only select the pdf attachments (everything else is grayed out), use drag&drop* to export them.

But... for some strange reason the search returns empty. I can get results when I check the "include partens and child items" box, but then the nice select-all solution doesn't work anymore because it selects the parent items, too.
This seems to just be the case for collections - if I search for
"Tag is XXX" and "Attachment file type is PDF" or some other first criterium this works just as expected.

This in on Zotero 2.0.3, FF 3.6.6 on Ubuntu 10.04
a) could someone confirm this behavior?
b) is that a bug or intended behavior/am I missing something?

*obviously drag&drop is still broken on Linux and I'd love it to get fixed, but here I'm trying to fix this for someone else.
  • edited July 20, 2010
    I get the same behavior (search is empty when "Collection is" is set to a collection that has items with PDF attachments, and "Attachment File Type is" is set to PDF).

    Here is the SQL query that produces the empty list:


    SELECT itemID
    FROM items
    WHERE itemID NOT IN (SELECT itemID FROM deletedItems
    UNION SELECT itemID FROM itemNotes
    WHERE sourceItemID IS NOT NULL AND
    sourceItemID IN (SELECT itemID FROM deletedItems)
    UNION SELECT itemID FROM itemAttachments
    WHERE sourceItemID IS NOT NULL AND
    sourceItemID IN (SELECT itemID FROM deletedItems)
    ) AND
    itemID IN (SELECT itemID FROM itemAttachments
    WHERE (mimeType LIKE application/pdf%)
    ) AND
    itemID IN (SELECT itemID FROM collectionItems
    WHERE (collectionID IN (79))
    )
    Where "79" is the collectionID of the collection in which I wanted to search. The last itemID clause may be the source of trouble, if the itemID of an attachment is not recorded as an immediate member of the collection in which the parent is located. That would explain the behavior, anyway.
  • The last itemID clause may be the source of trouble, if the itemID of an attachment is not recorded as an immediate member of the collection in which the parent is located. That would explain the behavior, anyway.
    Yep. The workaround currently is to use two saved searches, one with [Collection] [is] [Foo] and "Include parent and child items" and the other with [Saved Search] [is] [Bar] and [Attachment File Type] [is] [PDF].

    At some point we probably need to have the search consider child items as being part of collections.

This is an old discussion that has not been active in a long time. Instead of commenting here, you should start a new discussion. If you think the content of this discussion is still relevant, you can link to it from your new discussion.