Last active
March 4, 2026 21:28
-
-
Save avernet/ee26f16596bd8404f675dd0485b7e647 to your computer and use it in GitHub Desktop.
Finds all descendants of the current item that are completed and contain the string "πβ‘", then uncomplete them and replace the string with "β "
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const TARGET = "πβ‘"; | |
| const REPLACEMENT = "β "; | |
| function getAllDescendants(item) { | |
| const results = []; | |
| for (const child of item.getChildren()) { | |
| results.push(child); | |
| results.push(...getAllDescendants(child)); | |
| } | |
| return results; | |
| } | |
| function itemNeedsUpdate(item) { | |
| const containsTarget = item.getName().includes(TARGET) || item.getNote().includes(TARGET); | |
| return item.isCompleted() && containsTarget && !item.isReadOnly(); | |
| } | |
| const descendants = getAllDescendants(WF.currentItem()); | |
| const itemsToUpdate = descendants.filter(itemNeedsUpdate); | |
| if (itemsToUpdate.length === 0) { | |
| WF.showMessage("No matching items found.", false); | |
| } else { | |
| WF.editGroup(() => { | |
| for (const item of itemsToUpdate) { | |
| WF.completeItem(item); | |
| if (item.getName().includes(TARGET)) | |
| WF.setItemName(item, item.getName().replaceAll(TARGET, REPLACEMENT)); | |
| } | |
| }); | |
| WF.showMessage(`Updated ${itemsToUpdate.length} item(s).`); | |
| setTimeout(WF.hideMessage, 5000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment