Example of renaming files with random numbers (padded)

Javascript renaming examples. Javascript renaming is supported in version 3 or newer.

Example of renaming files with random numbers (padded)

Postby Admin » Fri Jan 22, 2021 2:52 am

With Javascript renaming in BRU:

function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}

function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}

str = "" + getRandomInt(1, 999);
var pad = "0000"
str = pad.substring(0, pad.length - str.length) + str;
newName = str;

Admin
Site Admin
 
Posts: 2059
Joined: Tue Mar 08, 2005 8:39 pm

Return to Javascript Renaming


cron