#11 2013-03-20 05:59

narayan
Senior Member
Registered: 2009-02-08
Posts: 471

Re: A new renaming rule called Random?

Question was never "how" but "why"... wink

Offline

#12 2013-03-22 01:14

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,479

Offline

#13 2013-08-09 18:36

Max_Cohen
Member
Registered: 2013-08-09
Posts: 1

Re: A new renaming rule called Random?

Hi, this is my code to random change the filename;

var
  a, b, c: Integer;
  s: String;
begin
	Randomize;
	s := '';
	For a:=0 To 9 Do
		Begin
	 		b := RandomRange(1, 3);
	 		c := RandomRange(0, 26);
		 	If ( b = 1 ) Then
		 		b := 65 + c
	 		Else
	 			b := 97 + c;
		 	s := s + Chr(b);
		End;
               FileName := s + WideExtractFileExt(FileName);
end.

Last edited by Max_Cohen (2013-08-09 18:37)

Offline

#14 2013-08-11 14:07

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,479

Re: A new renaming rule called Random?

Good work Max.

Just a small note on improving your script: Randomize function should only be called once during initialization of the script, otherwise the randomness distribution is reset on every filename and some properties of randomness are lost. To find you how to initialize a script have a look at this example: ReNamer:Scripts:Initialize.

You might also be interested in checking out this script: ReNamer:Scripts:Random_characters_and_length.

Offline

Board footer

Powered by FluxBB