RL Vision Knowledge Base

Support questions and answers for software by RL Vision.

Note: This is an archived discussion. Any bug, problem or suggestion mentioned here is likely to have been fixed since it was written.

Subject: Re: Randomising alist

Date: Sun, 18 Jan 2009 16:59:38 +0100

Hi again,

I was thinking about the unique random number thing, and ended up making a script to perform this. In the future I might integrate it into the program too. I have attached the script in this letter. Scripts are kind of advanced, so please read up on them in the manual, but I don't think it should be too much trouble for you work out!

Also, I have now fixed the bug with the Rnd# tag, so it will be available in the next update!

// Dan



Eb wrote:
> Hi Dan,
> thanks for your speedy response. I have been a bit too busy to evaluate your reply until now; ----something to do with irons and fires I think!
> I did find a method of achieving my goal by using a random range of 1 to 999 for 60 items which pretty much guaranteed no repeat numbers, and then added a counter and deleted the original random numbers; which I reckon is much as you suggested. I have realised that using the range 0 to 9 is just as valid because the following surnames would stop an duplicity from having any effect after being sorted. I have tried the 'free format' function as you suggest but I can only get it to work with the default range of 0-9, any other range specified results in the numbers and symbols being inserted as a string into the filenames with no random number being generated.
> Anyway, despite the problems encountered I will register your prog for my Photo Society when I can get confirmation from our treasurer that I can recoup the outlay!
> Cheers for now,
> Eb
> www.dabbles.co.uk
> http://buryps.co.uk/
>
> RL wrote:
>> Hi,
>>
>> I've never though about needing unique random numbers, but it does sound fair so I will try to add it in future versions.
>>
>> As for the problem you are having with the rnd function, I just tested it myself and it is indeed a bug you've found.. I don't know how it got there, but i will fix it right away!
>>
>> Here is my solution to your problem:
>>
>> 1. Use for example the "free format" function, and enter
>> 2. The new filename appears in the preview column. But instead of renaming according to this, click on the column header. This will sort the files according to the random numbers.
>> 3. Type for example "_" to get a number sequence with unique numbers!
>>
>> Tip: the tag can be setup at the "numbers->add counter" tab.
>>
>> Good luck!
>>
>> // Dan
>>
>>
>> Eb wrote:
>>> Hi,
>>> I'm interested in your prog for the purpose of randomising a list of files which are, naturally, in alphabetical order. before I register I want to clear up a couple of problems........
>>> I have tried the function but the same number may appear more than once and I want it to only appear once; i.e. in a list of 24 items I want the filename to be preceded with a number between 01 and 24 and every number to be used once only.
>>> Can this be done?
>>> Also when I use the RND# function the stated range appears in the new filename such as 15#-1-24]-_filename.jpg where 15 is the random number and #-1-24] is taken from the range 1 to 24. I then need to remove the #-1-24] as another step of renaming. Is this right?
>>>
>>> Your advice will be welcome,
>>> Thanks,
>>> Eb
>>>
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG - http://www.avg.com
>> Version: 8.0.176 / Virus Database: 270.10.6/1888 - Release Date: 1/12/2009 7:04 AM
>>
>>



language=vbscript
description=This script generates a random number within a range, where each number will be unique. Set the range using the input arguments like this: "Low-High", for example "5-20" (without the quotes). If you get an error there is probably a problem with the range you have typed in.

'------------------------------------------------------------------------------------------------
'Do not modify this script! It might be overwritten by the installer if
'you upgrade Flash Renamer. Make a copy of it and modify that instead.
'------------------------------------------------------------------------------------------------

Dim myNumbers()
Dim LowValue
Dim HighValue
Dim iCounter

Function Init()

Randomize

tmp = Split( FlashRenamer.Args , "-" )
if UBound(tmp) = 1 then
LowValue = CInt(tmp(0))
HighValue = CInt(tmp(1))
end if

if HighValue >= 30000 then
msgbox("Upper limit is too high!")
exit function
end if
if LowValue+HighValue >= 30000 then
msgbox("Numbers too high!")
exit function
end if

ReDim myNumbers( LowValue + HighValue + 1 )

For n = LowValue to HighValue
myNumbers(n) = n
Next

iCounter = LowValue

'shuffle numbers
for n = LowValue to HighValue
n2 = Int((HighValue - LowValue + 1) * Rnd + LowValue)
tmp = myNumbers(n)
myNumbers(n) = myNumbers(n2)
myNumbers(n2) = tmp
Next

End Function

Function Rename()

if iCounter > HighValue then
exit function
end if

Rename = CStr(myNumbers(iCounter))
iCounter = iCounter + 1

End Function

Unique Random Numbers.frs


Back to Knowledge Base


 · Software
 · Download
 · Order



 RL Vision
 · About
 · Contact
 · News
 · Blog



 Shareware
 · Flash Renamer
 · PDF Img Extract
 · Exif Tag Remover
 · Dupli Find



 Freeware
 · Replace Genius
 · Office Img Extract
 · Notepad2 BE
 · PhotoSift
 · CCTime
 · Hot Spot Studio
 · Snap2HTML
 · Snap2IMG
 · Bubble Math
 · DinnerWiz
 · NSF Tool
 · Beep.Exe



 Misc.
 · Changelogs
 · TitleQ
 · ArtGem
 · Graphics Tutorials
 · Win7 Font Bug
 · KB


Like my Freeware?

I'm on GitHub too!



© 1998-2024 RL Vision Privacy Policy