How do i mass-rename files to random names?

Post any Bulk Rename Utility support requirements here. Open to all registered users.

How do i mass-rename files to random names?

Postby Das_Unterstrich » Sat Oct 02, 2021 10:14 am

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?
Das_Unterstrich
 
Posts: 2
Joined: Sat Oct 02, 2021 9:39 am

Random rename from a custom list of characters

Postby Luuk » Sun Oct 03, 2021 2:16 am

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.
Luuk
 
Posts: 691
Joined: Fri Feb 21, 2020 10:58 pm

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

Postby Das_Unterstrich » Sun Oct 03, 2021 11:11 am

Okay thanks, but well no real solution for me because I don't have a commercial license.
Das_Unterstrich
 
Posts: 2
Joined: Sat Oct 02, 2021 9:39 am

Random rename from a custom list of characters

Postby Luuk » Sun Oct 03, 2021 10:31 pm

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.
Luuk
 
Posts: 691
Joined: Fri Feb 21, 2020 10:58 pm

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

Postby Admin » Tue Oct 05, 2021 3:14 am

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.
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Random rename from a custom list of characters

Postby Jakov » Sun Jan 16, 2022 7:30 pm

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
Jakov
 
Posts: 54
Joined: Sat May 23, 2020 1:29 am

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

Postby Luuk » Mon Jan 17, 2022 1:43 am

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)) {
Luuk
 
Posts: 691
Joined: Fri Feb 21, 2020 10:58 pm

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

Postby Jakov » Mon Jan 17, 2022 3:23 pm

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
Jakov
 
Posts: 54
Joined: Sat May 23, 2020 1:29 am


Return to BRU Support