Would it be possible to add the ability to delete all completed/checked Task List items in a document?
I tend to use Bike for a lot of to do lists, and when I end up with a bunch of checked-off items, I then have to go and manually delete those rows. It would be good to be able to hit a keyboard shortcut and have them all be deleted at once.
I don’t really like offering scripts which delete,
but it is possible to write a script which does this,
and assign a keystroke to it.
A rough draft – not for live use – just for experimenting on dummy data,
might look something like this:
Expand disclosure triangle to view JS source
(() => {
"use strict";
// NB ONLY FOR TESTING ON DUMMY DATA
// NOT RECOMMENDED FOR LIVE USE ON REAL FILES.
// Deletes all rows in the front document which
// are checked as "done"
// Undoing this script would require a series of ⌘Z
// or `Edit > Undo` – undoing each deletion one by one.
const
bike = Application("Bike"),
doc = bike.documents.at(0);
return doc.exists()
? doc.rows.attributes()
.flat()
.flatMap(
attr => "data-done" === attr.name()
? (() => {
const
doneRow = attr.containerRow(),
k = doneRow.name();
return (
doneRow.delete(),
k
);
})()
: []
)
.join("\n")
: "No document open in Bike.";
})();
To test in Script Editor, set the language selector at top left to JavaScript (rather than AppleScript)
Thank you, @complexpoint. I’ll have a play with this. Totally understand about being hesitant with handing out scripts that delete, but I did use an app (whose name escape me right now), that did just this for done items.
A slightly fuller script, combined with the filePath of an archive.bike file,
could remove them from the front document and append them to the archive.