Possible to search/replace a character in all titles?
I've just imported a heap of entries from Papers3, and quite a few of the file titles have a { character in-front.
Is it possible to do some type of bulk search/replace, or regex to remove the "{" character if it is at the start of the file title?
https://i.imgur.com/iMTOzv4.png
Is it possible to do some type of bulk search/replace, or regex to remove the "{" character if it is at the start of the file title?
https://i.imgur.com/iMTOzv4.png
Then enable and open the Run JavaScript window:
188BET靠谱吗//www.brodersterzo.com/support/dev/client_coding/javascript_api#running_ad_hoc_javascript_in_zotero
Then run this code to see the titles that would be affected:
188BET靠谱吗var s = new Zotero.Search();
188BET靠谱吗s.libraryID = Zotero.Libraries.userLibraryID;
s.addCondition('itemType', 'is', 'attachment');
s.addCondition('title', 'contains', '{');
var ids = await s.search();
if (!ids.length) {
return "No items found";
}
var titles = [];
for (let id of ids) {
188BET靠谱吗let item = Zotero.Items.get(id);
let title = item.getField('title');
if (title.startsWith('{') && !title.includes('}')) {
titles.push(title);
}
}
return titles;
And run this code to fix them:
188BET靠谱吗var s = new Zotero.Search();
188BET靠谱吗s.libraryID = Zotero.Libraries.userLibraryID;
s.addCondition('itemType', 'is', 'attachment');
s.addCondition('title', 'contains', '{');
var ids = await s.search();
if (!ids.length) {
return "No items found";
}
for (let id of ids) {
188BET靠谱吗let item = Zotero.Items.get(id);
let title = item.getField('title');
if (title.startsWith('{') && !title.includes('}')) {
item.setField('title', title.substr(1));
await item.saveTx();
}
}