Created
March 4, 2026 21:30
-
-
Save avernet/28a781331c2c417a80157a110ea37a23 to your computer and use it in GitHub Desktop.
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 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) { | |
| 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