Random numeral rename, with hyphens... in a button

Hi,
I have been using a batch script from howtogeek.com for a few years now that renames all files in a folder with random numerical sequence.

The .bat requres a confirmation, and creates a translation.txt that allows it to reverse the action.

I am asking if anyone could create a button for Dopus that renames all files in a folder with the same random numerical renaming pattern including the hyphens, without the need for confirmation or creating the translation.text

I have tried editing the script myself, I can only seem to break it, and even thinking about regular expressions gives me a migraine.

Thanks in advance, Peter.

It's much easier to make such from scratch opposed to adjusting the batch file, essentially just renaming files to [0-32767]-[0-32767]-[0-32767] (to simulate the !RANDOM!-!RANDOM!-!RANDOM!).

Standard Function for selected files:

RENAME PATTERN="*" TO="*"
@script JScript
function OnGetNewName(getNewNameData) {
 return Math.round(Math.random()*32767)+'-'+Math.round(Math.random()*32767)+'-'+Math.round(Math.random()*32767)+getNewNameData.item.ext;
}

For renaming all files in the folder (opposed to just the selection), you can add this to the top:

SELECT ALLFILES

I know it's not the prettiest (each Math.round can be put in a separate function or loop to call for each random number generation), but it's functionally the same.

4 Likes

Username checks out.
I failed to grasp introductory Basic back in the early eighties, so, although you may describe your solution as "not pretty", I'll put forward my view that it is actually bloody beautiful!
Thanks Pro, much appreciated!

2 Likes