[Share] Add reading
tag and remove unread
tag when opening a file
#445
Jensen-Inequality
started this conversation in
Action Scripts
Replies: 2 comments
-
Similar code follows. // Add `read` tag and remove `unread` or `reading` tag when appending a note
// Skip if `read` or `explore` tag exists
// @author ChatGPT
// @usage Event=Append Note
// Tags to check and modify
const tagToAdd = "read"; // Tag to add
const tagsToRemove = ["unread", "reading"]; // Tags to remove if present
const tagsToSkip = ["read", "explore"]; // Tags to skip if present
// Check if the item already has one of the tags to skip
if (item.getTags().some(obj => tagsToSkip.includes(obj.tag))) {
return `[Modify Tags] tag ${tagsToSkip.join(", ")} found, skipping on ${item.getField("title")}`;
}
// Remove the 'unread' or 'reading' tag if present
tagsToRemove.forEach(tag => {
if (item.getTags().some(obj => obj.tag === tag)) {
item.removeTag(tag);
return `[Modify Tags] removed tag ${tag} from ${item.getField("title")}`;
}
});
// Add the 'read' tag if none of the skipped tags are present
item.addTag(tagToAdd);
return `[Modify Tags] added tag ${tagToAdd} to ${item.getField("title")}`; |
Beta Was this translation helpful? Give feedback.
0 replies
-
Add // Add `explore` tag and remove `unread`, `reading` or `read` tag
// Skip if `explore` tag exists
// @author ChatGPT
// @usage Event=None
// Tags to check and modify
const tagToAdd = "explore"; // Tag to add
const tagsToRemove = ["unread", "reading", "read"]; // Tags to remove if present
const tagsToSkip = ["explore"]; // Tags to skip if present
// Check if the item already has one of the tags to skip
if (item.getTags().some(obj => tagsToSkip.includes(obj.tag))) {
return `[Modify Tags] tag ${tagsToSkip.join(", ")} found, skipping on ${item.getField("title")}`;
}
// Remove the 'unread', 'reading' or 'read' tag if present
tagsToRemove.forEach(tag => {
if (item.getTags().some(obj => obj.tag === tag)) {
item.removeTag(tag);
return `[Modify Tags] removed tag ${tag} from ${item.getField("title")}`;
}
});
// Add the 'explore' tag if none of the skipped tags are present
item.addTag(tagToAdd);
return `[Modify Tags] added tag ${tagToAdd} to ${item.getField("title")}`; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
Add
reading
tag and removeunread
tag when opening a file.Skip if
reading
,read
orexplore
tag exists.This script is written by ChatGPT, for which I do not know if it is proper to share. But it runs smoothly on my computer.
Event
Open File
Operation
Script
Data
Anything else
No response
Beta Was this translation helpful? Give feedback.
All reactions