I stumbled across
this and thought it would make a good starting point for a JS macro. Having tried it on a couple of TWs (where I had a ton of archaic temp/state tiddlers I wanted to remove) it seems there is a very destructive bug in there somewhere -- it destroys the TW (and since the wikis have passwords, they will no longer decrypt). The size of one of the wikis went from ~6.5MB to 103KB. Ouch.
Here is Tobias' original code:
var filter = "tag[FOO]";
filter = "[all[tiddlers]!prefix[$]" + subfilter + "]";
var tids = $tw.wiki.filterTiddlers(filter, null);
if(confirm('Delete all ' + tids.length + '?\n\n' + tids)){
for(var t=0; t<tids.length; t++) {
$tw.wiki.deleteTiddler(tids[t]);
}
}
Noticing the stray subfilter variable, I cleaned it up and then used this:
var filter = "[prefix[$:/temp/state/1]]";
var tids = $tw.wiki.filterTiddlers(filter, null);
if(confirm('Delete all ' + tids.length + '?\n\n' + tids)){
for(var t=0; t<tids.length; t++) {
$tw.wiki.deleteTiddler(tids[t]);
}
}
If I use that filter in the filter search input in TW, it works as expected. When running the code above, it lists the exact same tiddlers (AFAICT), yet, it destroys the TW on confirming the dialog.
Anyone see a problem? What am I missing?
TIA
Edited to change 6.5KB to 6.5MB (oops)