I found the script I actually use for my bookmarklet, which I wrote when this topic was first posted, and meant to share then, but totally forgot. The code looks like this:
const filename = ($tw.wiki.getTiddler('$:/config/SaveWikiButton/Filename')?.fields?.text ?? 'MyTiddlyWiki.html')
.replace(/\.([^\.]+)$/, (_, ext) => '-' + new Date().toISOString().replace(/\D/g, '') + '.' + ext);
$tw.saverHandler.saveWiki({
template:"$:/core/save/all",
method: "download",
downloadType: "text/plain",
variables: {filename}
})
Which generates bookmarklet code of
javascript:(function()%7Bconst%20filename%20%3D%20(%24tw.wiki.getTiddler('%24%3A%2Fconfig%2FSaveWikiButton%2FFilename')%3F.fields%3F.text%20%3F%3F%20'MyTiddlyWiki.html')%0A%20%20%20%20%20%20.replace(%2F%5C.(%5B%5E%5C.%5D%2B)%24%2F%2C%20(_%2C%20ext)%20%3D%3E%20'-'%20%2B%20new%20Date().toISOString().replace(%2F%5CD%2Fg%2C%20'')%20%2B%20'.'%20%2B%20ext)%3B%0A%24tw.saverHandler.saveWiki(%7B%0A%20%20template%3A%22%24%3A%2Fcore%2Fsave%2Fall%22%2C%20%0A%20%20method%3A%20%22download%22%2C%0A%20%20downloadType%3A%20%22text%2Fplain%22%2C%20%0A%20%20variables%3A%20%7Bfilename%7D%0A%7D)%7D)()%3B
The instructions above still apply:
To use, create a bookmark (perhaps of this page), then edit the bookmark (right-click on most desktop browsers), and enter the above as the URL, changing the title as you see fit. Then click it on any wiki, and it will offer a backup file whenever you like.
And it generates file names like NRT_Balancing_Notes-20241126213219815.html
or TTEC_Chess-20241126212235734
, or if you don’t have a value in $:/config/SaveWikiButton/Filename
, just MyTiddlyWiki-20241126213459896.html
. The timestamps are the same style as used internally by TW, although I use local time rather than UTC.
The name MyTiddlyWiki.html
might not suit you for a generic backup. Just replace that in the bookmarklet code with whatever you prefer, perhaps, tiddlywiki.html
.
But a significant limitation is that this doesn’t take into account the techniques from another recent thread, which allows you to build a timestamp into your filename. I will try to ponder this later, as I think it would be useful to handle that case as well.