Add tag to items from a list of authors?
Would there be any way to tag items in my library from a list of authors?
For example, I’d have a file authors.txt looking like:
Smith, John
Einstein, Albert
...
and I would want every item where these authors appear in my library to be tagged with some specific tag.
Is there a way I could do that?
For example, I’d have a file authors.txt looking like:
Smith, John
Einstein, Albert
...
and I would want every item where these authors appear in my library to be tagged with some specific tag.
Is there a way I could do that?
var file = '/Users/dan/Desktop/authors.txt';
var s = new Zotero.Search;
s.libraryID = ZoteroPane.getSelectedLibraryID();
s.addCondition('joinMode', 'any');
var file = await Zotero.File.getContentsAsync(file);
var lines = file.split(/\n/);
for (let line of lines) {
// Split at comma and reverse order
let names = line.split(/,\s*/);
let name = (names[1] + ' ' + names[0]).trim();
s.addCondition('creator', 'contains', name);
}
var itemIDs = await s.search();
ZoteroPane.selectItems(itemIDs);
Then drag the selected items to a tag in the tag selector.