Gino
Wed Jan 31 21:09:24 CST 2007
I agree. Looking at it I think what will happen is if the number of files
pool was around 1000 and I was selecting 100 the high end number would never
get above 300.
Thanks for pointing that out.
"Richard Mueller [MVP]" <rlmueller-NOSPAM@ameritech.NOSPAM.net> wrote in
message news:%23YoFLHYRHHA.412@TK2MSFTNGP02.phx.gbl...
> The Randomize function should be used once at the beginning of the script,
> to seed the random number generator with a value based on the system time.
> If you call Randomize before each call to Rnd, the resulting sequence will
> no longer be random, since you are continually re-seeding the generator.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab web site -
http://www.rlmueller.net
> --
>
> "Gino" <someone@microsoft.com> wrote in message
> news:%23xAglSoQHHA.4632@TK2MSFTNGP04.phx.gbl...
>> 'Hope this helps the rain in spain.
>> 'Watch for line wrap.
>>
>> Dim objFso
>> Dim objDictionary
>> Dim fileCount
>> Dim numberArray(100)
>> Dim indexNum
>> indexNum = 0
>>
>> Set objFso = CreateObject("scripting.filesystemobject")
>> Set objFolder = objFso.GetFolder("C:\Data")
>> Set objFiles = objFolder.Files
>> fileCount = objFiles.Count
>> Set objDictionary = CreateObject("scripting.dictionary")
>>
>> For Each fileName In objFiles
>> objDictionary.Add indexNum, fileName
>> indexNum = indexNum + 1
>> Next
>> 'WScript.Echo objDictionary.Item(10)
>> For i = 0 To 99
>> Randomize
>> RandomNumber = Int((fileCount * Rnd) + 1)
>> numberArray(i) = RandomNumber
>> Next
>>
>> For j = 0 To 99
>> For k = 0 To 99
>> If numberArray(k) = numberArray(k + 1) Then
>> numberArray(k) = numberArray(k) + 1
>> End If
>> If numberArray(k) > numberArray(k + 1) Then
>> temp = numberArray(k + 1)
>> numberArray(k + 1) = numberArray(k)
>> numberArray(k) = temp
>> End If
>> Next
>> Next
>>
>> For L = 1 To 99
>> objFso.CopyFile objDictionary.item(numberArray(L)), "C:\Destination\"
>> Next
>>
>> Set objFso = Nothing
>> Set objDictionary = Nothing
>>
>> "Juan in msnews" <juan_magana@hotmail.com> wrote in message
>> news:elA5f4JQHHA.992@TK2MSFTNGP06.phx.gbl...
>> > Hi everyone,
>> >
>> > I'm trying to create a script that gives the user the option to select
>> > a
>> > source folder and a destination folder. What I want to do is:
>> >
>> > - delete all files in destination folder
>> > - randomly, copy files from the source folder to the destination
>> > folder,
>> > until destination folder is full
>> >
>> > But I'm having trouble with the second part, since I don't know how to
> use
>> > the Rnd function to randomly select files in the source folder.
>> >
>> > Any ideas?
>> >
>> > Thanks, from Spain
>> >
>> >
>> >
>>
>>
>
>