Page 1 of 1

How do i mass-rename files to random names?

PostPosted: Sat Oct 02, 2021 10:14 am
by Das_Unterstrich
I basically have a lot of pngs with names like
    image1.png | 2021-09-01.png | 172612.png | etc
and would like to rename them all to having 5 random characters, for example
    utOgK.png | bt9u7.png | WrCcr.png
I looked through the manual and some forum posts already, but didn't really find any way to do it. Am I just overlooking something?

Random rename from a custom list of characters

PostPosted: Sun Oct 03, 2021 2:16 am
by Luuk
With having the paid version, javascript can choose random-characters from inside a custom-list like...

if (/png/i.test(ext)) {
function random() {
string = ''
list = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
for (var i=0; i<5; i++) {string += list.charAt(Math.random()*list.length)}
return string}
newName = random()}

If needing to save the original-names inside of the metadata, Im often use the exiftool.exe to conduct this instead.
But also after renaming, the bulk rename utility grants "Actions, Create Undo Batchfile" to help restore the original-names.

Re: How do i mass-rename files to random names?

PostPosted: Sun Oct 03, 2021 11:11 am
by Das_Unterstrich
Okay thanks, but well no real solution for me because I don't have a commercial license.

Random rename from a custom list of characters

PostPosted: Sun Oct 03, 2021 10:31 pm
by Luuk
This some different ways to experiment the same with having the free exiftool.exe, but its a command-line application!...

exiftool -ext png -fast4 -Testname"<${Filename;my $x;$x.= ['A'..'Z','a'..'z',0..9]->[rand 62] for 1..5;$_=$x}.png" "C:/Your/Folder/Path"
Conduct all .png files inside 'C:/Your/Folder/Path' without saving the original-names.

exiftool -r -ext png -fast4 -Testname"<${Filename;my $x;$x.= ['A'..'Z','a'..'z',0..9]->[rand 62] for 1..5;$_=$x}.png" "C:/Your/Folder/Path"
Cconduct all .png files at or below 'C:/Your/Folder/Path' without saving original-names.

exiftool -r -ext png -overwrite_original -Testname"<${Filename;my $x;$x.= ['A'..'Z','a'..'z',0..9]->[rand 62] for 1..5;$_=$x}.png" -Document"<Filename" "C:/Your/Folder/Path"
Conduct all .png files at or below 'C:/Your/Folder/Path' while saving the original-names inside of each file's $Document metadata.

Each command will only present a preview looking like... "Path/OldNames.png" --> "Path/NewNames.png".
So if ready and wanting to rename the files, you can then just change -Testname ===> -Filename.

The -fast4 tells exiftool.exe to not conduct any metadata, so then -overwrite_original isnt needed, because its just renaming files.
The -r does just say "recurse all folders", but there is also many other ways to only conduct certain sub-folders or files.

Re: How do i mass-rename files to random names?

PostPosted: Tue Oct 05, 2021 3:14 am
by Admin
You could export your file list to CSV (select all the files to rename in the BRU list and right-click and then "Clipboard Copy") then paste them into Excel or another spreadsheet software. Then create random files with the spreadsheet software and export to CSV and import CSV into BRU to rename.

Re: Random rename from a custom list of characters

PostPosted: Sun Jan 16, 2022 7:30 pm
by Jakov
Luuk wrote:if (/png/i.test(ext)) {
function random() {
string = ''
list = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
for (var i=0; i<5; i++) {string += list.charAt(Math.random()*list.length)}
return string}
newName = random()}


Dear Luuk,
Thank you for this awesome javascript code
please how to use this code to rename all files in certain folder to random names regardless of the file extension (not specific file extension, ex: not just png files)
Thank you

Re: How do i mass-rename files to random names?

PostPosted: Mon Jan 17, 2022 1:43 am
by Luuk
Greetings Jakov. On the very first line, you could just change the /png/ ===> /./
This to rename any files having at least 1-character in the extension, without renaming folders.

But if some files dont have extensions, then the whole line should be... if (!object('isdir')) {
This to rename all files, even if not having extensions, and also without renaming any folders.

If to only rename certain extensions like bmp, txt, png, jpg, jpeg, etc, then the whole line could look like...
if (/^(bmp|txt|png|jpe?g)$/i.test(ext)) {

Re: How do i mass-rename files to random names?

PostPosted: Mon Jan 17, 2022 3:23 pm
by Jakov
Luuk wrote:Greetings Jakov. On the very first line, you could just change the...............
{


Thank you so much dear Luuk
I rarely deal with files that have no extension

Thanks for being such a star
Much Obliged
Thank you, I really appreciate your help
Best Regards