Collection Tags [Share] #245
Replies: 7 comments 8 replies
-
Very useful and highly needed. Thank you very much |
Beta Was this translation helpful? Give feedback.
-
Thank you for providing the script. I can add tags by triggering the script manually, but I can't seem to run the script when events such as opening a document or adding an item occur. Is there any way to solve this? Thank you! |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answer, I was talking about adding comments to the pdf. I tried some more and the current script is working. Whenever I add highlighted notes in the pdf, zotero-action-tags automatically adds the collection as tags. This is fantastic, thanks a lot! |
Beta Was this translation helpful? Give feedback.
-
This is really nice, thank you! I'd like to have nested sub-collections combined in a single tag as "#Collection/Sub-collection" rather than as separate tags for each sub-collection. I'm not much of a coder but if you have any advice on how I could modify the script to achieve this I'd really appreciate it! |
Beta Was this translation helpful? Give feedback.
-
Hi, this command is very helpful. However, there is a little problem when I create the and this command will also add the prefix number to the tag, so any idea to handle this? |
Beta Was this translation helpful? Give feedback.
-
Hi, I made a slight modification to the function function CollNames2TagNames(collNames) {
if (trimLeadingUnderscores)
collNames = collNames.map((c) => c.replace(/^_+/, "").trim());
if (trimLeadingNumbers)
collNames = collNames.map((c) => c.replace(/[0-9]+/, "").trim());
// Convert to lowercase and replace spaces with hyphens
collNames = collNames.map((c) => c.toLowerCase().replace(/\s+/g, "-"));
switch (tagStyle) {
case "separate":
return collNames.map((c) => tagPrefix + c);
case "path":
return [tagPrefix + collNames.join("/")];
default:
throw "[Tag Collections] An error occurred while processing collection names.";
}
} |
Beta Was this translation helpful? Give feedback.
-
Could you tell me the specific application scenario? I didn't understand the script |
Beta Was this translation helpful? Give feedback.
-
Description
Add tags corresponding to an item's collection(s). This script is intended for the item or collection menu but also works when adding new items.
When triggered from the collection menu, tag(s) are added to all items in the collection. If
recursive
is true, tags are added for each level of nestedness in the collection/subcollections. For example, if run on a collection namedmusic
with a subcollection namedrhythm
, all items inrhythm
would be tagged withmusic
andrhythm
, but items inmusic
would only be tagged withmusic
. Only the parent collection tag is added whenrecursive
is false.When triggered from the item menu, tags are added based on the currently selected collection. So, running this script on an item (or items) in
rhythm
would only add therhythm
tag.Event
None, createItem
Operation
Script
Data
Beta Was this translation helpful? Give feedback.
All reactions