Word randomizer script

Advanced Renamer forum
#1 : 21/08-20 20:00
Alien
Alien
Posts: 1
Hello,

I am looking for a script that can randomize a string of words to add to the file name.
In a previous forum thread I found this script:

var colors = ["Red", "Green", "Blue", "Cyan", "Yellow", "Purple"];
return colors[Math.floor((Math.random() * colors.length))];

This works great, except it only outputs one of the colors.
This script can output the entire randomized string in a Javascript console, but I dont know how to adapt it to Advanced Renamer:

const shuffle = array => array.sort(() => Math.random() - 0.5).toString()
const colors = ["Red", "Green", "Blue", "Cyan", "Yellow", "Purple"];
console.log(shuffle( colors ))

How can the scripts be adapted to work?


21/08-20 20:00
#2 : 22/08-20 11:03
David Lee
David Lee
Posts: 517
Advanced Renamer does not support JavaScript ES6 extensions so you will have to use the original verbose function syntax:

function shuffle (array) {
return array.sort(function(){return 0.5 - Math.random()});
}
colors = ["Red", "Green", "Blue", "Cyan", "Yellow", "Purple"];
app.log(shuffle( colors ));

app.log writes output to the "JS Console" (main menu item).

Note that this will only work if you have at least one item in the List.


22/08-20 11:03
#3 : 04/09-20 11:31
Jorge Burnette
Jorge Burnette
Posts: 1
A debt of gratitude is in order for sharing this data in a word. Your post is straightforward which is remarkably useful for the peruser. I need to develop my automaton business and for that I am looking for the tips on the web. I have additionally discovered helpful data on https://www.ogscapital.com/business-plan/bank-sb a-business-plan/. Furthermore, presently I am contemplating making my automaton business site and for that I am looking for tips on the web.


04/09-20 11:31 - edited 04/09-20 11:33