Call Randomize() to initialize the random number generation algorithm somewhere in your script, prior to the first call to Rnd()

 

Could I suggest you get the Windows Script Host 5.6 documentation:

http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

 

Some of the things you are running into are dealt with more quickly by just looking up the relevant topics…

 

Cheers

Ken

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Kern
Sent: Friday, 9 December 2005 5:08 AM
To: [email protected]
Subject: Re: [ActiveDir] _vbscript_ help(OT)

 

Thanks alot!!

 

 

Unfortuantely it only seems to work when i ran it the first time.

 

if i kill it and run it again and it encounters a duplicate file  in the source dir it throws an error-"file already exisits".

 

will  it only work in one shot?

 

thanks
 

On 12/8/05, Rich Milburn <[EMAIL PROTECTED]> wrote:

Replace your last sub:

sub filelist(grp)

 for each file in grp.files

  if targ.files.count>=999 then full=true:exit for

   if lcase(fso.getextensionname(file)) = "eml" then

   set objFile = fso.getfile(file)

   arrFileName = Split(objfile.Name,".")

            oldname = arrFileName(0)

            ext = arrFileName(1)

            if fso.FileExists(target & objFile.Name) then

           

      newfile=oldname & cstr(int(Rnd * 1000)) & "." & ext

    Else

      newfile=objFile.Name

    end if

    wscript.echo newfile

   fso.MoveFile file,target & newfile 

 end if

  next

End sub

 

-----------------------------------------------------------------------
Rich Milburn
MCSE, Microsoft MVP - Directory Services
Sr Network Analyst, Field Platform Development
Applebee's International, Inc.

4551 W. 107th St
Overland Park, KS 66207
913-967-2819
----------------------------------------------------------------------
"I love the smell of red herrings in the morning" - anonymous

 

Reply via email to