Search for items which have non 'linked' files?

Apologies for asking two questions close to each other. I'm trying to identify items which have stored pdf's and not 'linked' pdfs which have been done by zotfile. Once identified I can run zotfile 'rename and move' and move to have all attachments in one location. Is there a way to formulate such an query in advanced search? Thank you
  • I don't think it's possible to do that with an advanced search.

    But this code run under Tools\Developer\Run Javascript will get you a list of PDF files that are in local storage (and are in the Zotero database):

    var datadir = Zotero.DataDirectory.dir;
    var sql = "SELECT (? || ? || key || ? || REPLACE(path,?,?)) AS filepathnames FROM itemAttachments JOIN items USING (itemID) WHERE libraryID=1 AND path IS NOT NULL AND path LIKE ? ORDER BY filepathnames";
    var filepathnames = await Zotero.DB.columnQueryAsync(
    sql,
    [
    datadir,
    '\\storage\\',
    '\\',
    'storage:',
    '',
    'storage:%.pdf'
    ]
    );
    return filepathnames.join('\n');

    The double backslashes are Windows-specific. You'd probably need to switch them to single forward slashes for Mac or Linux, but I haven't tested that.

    If it's not obvious which item some of the listed PDFs belong to, you can run a Quick Search for the listed folder name (eg 9GJA3BD2), set to All Fields & Tags or to Everything.

    If the list of PDFs is too long, you may be better off just doing Rename & Moves on your whole library, starting with just the A's, then the B's, etc etc.
  • Thank you for this detailed reply. It's brilliant. Giving the correct results. BY any chance, can this output be like selected in zotero? e.g. the resulting items get selected in zotero?
  • Sorry I don't know any way to get the linked PDFs in the javascript list selected in Zotero. Adding the capability to search for linked PDFs in Advanced Search would be the best way to address that, ie a new option to set Attachment File Type is Linked PDF. So I guess that's a Feature Request. ;)
Sign In or Register to comment.