Rename - Randomize Function

Have a suggestion for "Everything"? Please post it here.
Post Reply
therube
Posts: 4979
Joined: Thu Sep 03, 2009 6:48 pm

Rename - Randomize Function

Post by therube »

Everything Rename - Randomize Function, RND()

Might be nice to have a Randomize Function.
Such that say you could take a set of names that you could then change.

Code: Select all

060975902c5dacb88d1f2128eb85aa406d6d79f5b8
0a06807c8f9748d4e8fb76af98ad53aa3082949504
0ec6bf5b49cb29a78d005576ed0f8b6fc5283328f5
0f21ec17b7fbd963a20bd9fcba0bcc24895736d0c9
103d6e35897eadeaf1c4fe211cedd2c11a24ee5610
1219e2a8978f7f1d02a7ce302dcddcae6ce29079a8
$rnd(3,a); alpha

abc
cba
xyz
jaq

$rnd(3,A); alpha-numeric

a1c
3ba
x77
jaq

$rnd(3,n); numeric

123
321
000
996
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: Rename - Randomize Function

Post by void »

I've added to my TODO list: add a scripting language to the Everything renamer.

Something like:
$eval(Math.floor(math.random() * 26) + 'a')

Thanks for the suggestion.

Why random though? would generating a hash be more useful? eg the md5sum, sha1 or sha256 hash of part of the filename?
therube
Posts: 4979
Joined: Thu Sep 03, 2009 6:48 pm

Re: Rename - Randomize Function

Post by therube »

In this instance, I was just thinking of long file names (path+file name), where some of the directories are similar to what is noted above, & if I could shorten them such that the total path length < ~255, it would be less trouble for other programs that would otherwise have trouble dealing with such paths (& files).

So if I periodically, path:len:>254, then if there is something common, like a directory tree with rather worthless random-ish paths, by shortening the rather long-ish path parts, so if I dropped from say a 20 character path segment to a (random, & random because in this case the actual path part name is immaterial) 3 character path, I've saved 17 characters, & with that a greater possibility of dropping below 255 char path lengths where many programs have issues.
runmode
Posts: 21
Joined: Sat May 27, 2023 11:22 pm

Re: Rename - Randomize Function

Post by runmode »

I vote for a pseudo-random alpha-numeric string generating function, to be used with Advanced Renamer.
My usage: insert pseudo-unique (but short) tokens into picture file names, which can then be referenced easily from anywhere, e.g. on a web site.

Regarding your proposal to use hashes: I could calculate a md5 hash from the full filename including the path, because the file names are to short and redundant. But are hashes limited to [0123456789abcdef] which would result in longer strings than [0...z] ? From the md5 I would use only the first 10 characters, to keep file names short. The number of possibe combinations would be again lower and the chance for duplicates higher.

Please, consider my feature request for an alpha-numeric randomizer, with a custom list of included characters, to utilize the range of the file system (for NTFS case-insensitive, optionally including [§$%&=#~ etc]).
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: Rename - Randomize Function

Post by void »

Everything 1.5 adds a [rand:] preprocessor function.

For example:

Code: Select all

[rand:"%10"]
[rand:"%10"][rand:"%10"][rand:"%10"]
[rand:"%10"][rand:"%10"][rand:"%10"][rand:"%10"][rand:"%10"][rand:"%10"][rand:"%10"][rand:"%10"]

Code: Select all

[unichar:65+[rand:"%26"]]
[unichar:65+[rand:"%26"]][unichar:65+[rand:"%26"]][unichar:65+[rand:"%26"]]
[unichar:65+[rand:"%26"]][unichar:65+[rand:"%26"]][unichar:65+[rand:"%26"]][unichar:65+[rand:"%26"]][unichar:65+[rand:"%26"]][unichar:65+[rand:"%26"]][unichar:65+[rand:"%26"]][unichar:65+[rand:"%26"]]

Code: Select all

[mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",1+[rand:"%36"],1]
[mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",1+[rand:"%36"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",1+[rand:"%36"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",1+[rand:"%36"],1]
[mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",1+[rand:"%36"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",1+[rand:"%36"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",1+[rand:"%36"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",1+[rand:"%36"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",1+[rand:"%36"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",1+[rand:"%36"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",1+[rand:"%36"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",1+[rand:"%36"],1]

Code: Select all

[mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_§$%&=#~",1+[rand:"%44"],1]
[mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_§$%&=#~",1+[rand:"%44"],1]
[mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_§$%&=#~",1+[rand:"%44"],1]

Code: Select all

[crc64:$name:]
[md5:$name:]
[sha256:$name:]


Search Preprocessor
Advanced Rename
runmode
Posts: 21
Joined: Sat May 27, 2023 11:22 pm

Re: Rename - Randomize Function

Post by runmode »

Phantastic, thank you for the help :D
This is a good solution, while kind of bulky.
You tried to tell me that with the [md5:$name:] example ;)
So I tested include, please look at my screenshot
What went wrong with include? It is included but not expanded.
I have no line breaks (though I would like to).
Any alternatives to write custom functions?
Attachments
zn0UzU01jW.jpg
zn0UzU01jW.jpg (96.07 KiB) Viewed 5822 times
Last edited by runmode on Mon May 29, 2023 2:15 pm, edited 1 time in total.
therube
Posts: 4979
Joined: Thu Sep 03, 2009 6:48 pm

Re: Rename - Randomize Function

Post by therube »

;-)
[rand:"%0"]
[rand:"%99999999999999999999"]
- both give 0
[rand:"%^"]
- gives -1 (as does other "errors")
though that does give you a method to use a "negative" number (that will always be the same, at that)
[rand:"%999^"]
- does return good results, ignoring the ^
;-)


On a more serious note, while rand: may return random results, it does not (necessarily) return UNIQUE random results.
therube
Posts: 4979
Joined: Thu Sep 03, 2009 6:48 pm

Re: Rename - Randomize Function

Post by therube »

(What does include: do?
Is the "function" supposed to go in random8x44.txt or the names the function is supposed to act on?)
runmode
Posts: 21
Joined: Sat May 27, 2023 11:22 pm

Re: Rename - Randomize Function

Post by runmode »

viewtopic.php?f=12&t=10099

[include:filename]
Returns the text content from the file specified by filename.
"Can only be used from the main search window." :?

Well this remark is 2 years old, and worth to be tested - at least the text was included, but not expanded.
@void: Possibly a kind of eval: function could trigger to resolve the string?

I also tried [repeat:[mid:"abcdefghijklmnopqrstuvwxyz0123456789_§$%&=#~",1+[rand:"%44"],1],8] but it repeats one result of the argument - cannot be used as a loop.
void
Developer
Posts: 16753
Joined: Fri Oct 16, 2009 11:31 pm

Re: Rename - Randomize Function

Post by void »

The Everything preprocessor does not support loops.
[eval:...] does not execute the preprocessor. (only simple expressions)

Manually repeat the [mid:...] function for the desired number of characters:
[mid:"abcdefghijklmnopqrstuvwxyz0123456789_§$%&=#~",1+[rand:"%44"],1]

For example, 8 times:

Code: Select all

[mid:"abcdefghijklmnopqrstuvwxyz0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"abcdefghijklmnopqrstuvwxyz0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"abcdefghijklmnopqrstuvwxyz0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"abcdefghijklmnopqrstuvwxyz0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"abcdefghijklmnopqrstuvwxyz0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"abcdefghijklmnopqrstuvwxyz0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"abcdefghijklmnopqrstuvwxyz0123456789_§$%&=#~",1+[rand:"%44"],1][mid:"abcdefghijklmnopqrstuvwxyz0123456789_§$%&=#~",1+[rand:"%44"],1]
Post Reply