-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRandomString.js
More file actions
29 lines (26 loc) · 864 Bytes
/
RandomString.js
File metadata and controls
29 lines (26 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// RandomString
// Description: Replace `{randomString}` in the new name to random strings.
// Author: @Chaoses-Ib
// Version: 231121
// Homepage: https://github.com/Chaoses-Ib/IbDOpusScripts
function OnGetNewName(getNewNameData)
{
return getNewNameData.newname_stem_m.
replace(/\{randomString\}/g, function() {
// 8 is the length of the random string
return randomString62(8)
})
+ getNewNameData.newname_ext_m
}
function randomString62(len){
// Chars used to generate the random string
var table = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
var str = ""
for (i = 0; i < len; i++){
str += table.charAt(randomInt(0, table.length - 1))
}
return str
}
function randomInt(min, max){
return Math.round(min + Math.random() * (max - min)) // Not max-min+1
}