How to generate a random title?

Hello everyone

I’m looking to create a title of the form id-519268, with 6 randomly generated numbers behind the id.

Do you have any solutions ?

Thanks in advance

Hello, I have thought of a feasible way to create it using the browser console

var idPrefix = "id-";
var randomDigits = Math.floor(Math.random() * 1000000); // 生成一个 0 到 999999 之间的随机整数
var id = idPrefix + randomDigits;
console.log(id);

If you want to change the random id again, run the change code again in the browser console

Have a good time

Hi,

Good solution, but I’m really looking to automate the process in the tiddlywiki. f I have to manually restart the code every time I create a new tiddler, I’m not out xD

Here’s a small TiddlyTools macro that uses javascript Math.random() to generate a decimal random number between 0 and 1.

https://tiddlytools.com/#TiddlyTools%2FMacros%2FRandom.js

You can then use a TiddlyWiki filter to multiply and truncate to get a title with a random 6-digit number, like this:

<$let title={{{ [<random>multiply[1000000]trunc[]pad[6]addprefix[id-]] }}}>

enjoy,
-e

2 Likes

You can also use a random filter (plugin):
https://yaisog.tiddlyhost.com/#$:/plugins/yaisog/random-filter