How to rename files at random with BRU javascript?

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

How to rename files at random with BRU javascript?

Postby Admin » Tue Jun 03, 2025 9:08 am

Copy and paste in Bulk Rename Utility:

Code: Select all
// Rename files at random by assigning a random string as the new name
// This example uses a random 8-character alphanumeric string
// Example: name = "holiday.jpg" -> newName = "A7f2kL9q"
// Note: The extension is not changed here; only the name part

function getRandomString(length) {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    var str = "";
    for (var i = 0; i < length; i++) {
        str += chars.charAt(Math.floor(Math.random() * chars.length));
    }
    return str;
}

newName = getRandomString(8); // Change 8 to desired length

// Example:
// name = "holiday.jpg"
// newName = "A7f2kL9q"
Admin
Site Admin
 
Posts: 2923
Joined: Tue Mar 08, 2005 8:39 pm

Return to Javascript Renaming