[Share] Copy and paste tags of selected item(s) 复制粘贴所选条目的标签 #194
Replies: 17 comments 18 replies
-
https://getquicker.net/Sharedaction?code=16252683-cae2-4ced-492c-08db697c985a |
Beta Was this translation helpful? Give feedback.
-
Thanks very much for this; it works when I select the top-level/parent item, but when I try to copy the tags just for a note item (either below the parent item or elsewhere) it returns this (see the screenshot below), am I doing something wrong or do I need to modify the template? These are the current settings I have: Again, thank you if you manage to take a look at this at all!! |
Beta Was this translation helpful? Give feedback.
-
Thanks for the action. I started getting this error recently (e.g.
Do you have an idea how to fix this? |
Beta Was this translation helpful? Give feedback.
-
updated |
Beta Was this translation helpful? Give feedback.
-
It is not working for me to copy or paste tags on Standalone notes. |
Beta Was this translation helpful? Give feedback.
-
I think this script only works for regular item tag. |
Beta Was this translation helpful? Give feedback.
-
For the newest Zotero version I had to change |
Beta Was this translation helpful? Give feedback.
-
thanks a lot, it used to work, but now it doens't work for 7.0.0-beta.95+694ccecf4. Could you please update the script? |
Beta Was this translation helpful? Give feedback.
-
For the newest Zotero version I had to change item.isCollection() to item instanceof Zotero.Collection. |
Beta Was this translation helpful? Give feedback.
-
Here is an updated script working with
|
Beta Was this translation helpful? Give feedback.
-
Thanks a lot but the script does not allow to copy and paste tags from the notes in Zotero 7. Updated version would be very much appreciated! Thank you |
Beta Was this translation helpful? Give feedback.
-
有什么提示吗? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Hi, thank you very much for the scripts I get an warning message when I created both actions
|
Beta Was this translation helpful? Give feedback.
-
Hello! This worked for me a few days ago; now when I try it returns script error Zotero.Utilities.Internal.getClipboard (...) is null. Thanks for all your work on this. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
The following two scripts (copied and modified from previous comments) work with Zotero 7.0.11 + Actions & Tags build 2.1.0, and do not cause the warning message Copy tags// Copy tags script for Zotero Actions & Tags + Zotero 7
// Code from Zutilo (with modifications)
// 获取条目tags,并存入剪贴板
// Ensure 'items' is defined (passed to the script)
if (typeof items === 'undefined' || !items.length) {
Zotero.debug("No items selected.");
return false;
}
// Create empty array of tags
var tagArray = [];
// Copy tags from selected items into array
for (let item of items) {
if (item.isRegularItem() && !(item instanceof Zotero.Collection)) {
var tempTags = item.getTags();
for (var j = 0; j < tempTags.length; j++) {
let tag = tempTags[j].tag;
if (!tagArray.includes(tag)) {
tagArray.push(tag);
}
}
}
}
// Copy tags to clipboard as text
var clipboardText = tagArray.join('\r\n');
Zotero.Utilities.Internal.copyTextToClipboard(clipboardText);
return "Tags copied."; Paste tags// Paste tags script for Zotero Actions & Tags + Zotero 7
// Code from Zutilo (with modifications)
// 从剪贴板获取tags
// Ensure 'items' is defined (passed to the script)
if (typeof items === 'undefined' || !items.length) {
Zotero.debug("No items selected.");
return false;
}
// Get tags from clipboard (but abort if empty)
var clipboardText = Zotero.Utilities.Internal.getClipboard("text/plain").trim();
if (!clipboardText) {
Zotero.debug("Clipboard is empty.");
return false;
}
// Split the clipboard text into an array of tags
var tagArray = clipboardText.split(/\r\n?|\n/);
tagArray = tagArray.map(function (val) { return val.trim(); });
tagArray = tagArray.filter(Boolean);
// Add tags to each selected item
for (let item of items) {
if (item.isRegularItem() && !(item instanceof Zotero.Collection)) {
for (let tag of tagArray) {
item.addTag(tag);
}
item.saveTx();
}
}
return "Tags pasted."; |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Copy tags from item and paste them to another item.
复制、粘贴所选条目的标签
大部分代码来源于Zutilo。
感谢@windingwind指导。
Event
None
Operation
Script
Data
Action Data for COPY tags from item:
Action Data for PASTE tags to item:
Anything else
Note that you'll need to create TWO actions, one for copy and one for paste.
有些代码可能不需要,可以自行删除。
需要分别建立两个动作。
Beta Was this translation helpful? Give feedback.
All reactions