I have this _vbscript_ i wrote/stole to move all files with an .eml extension from many subdirs  into a folder only if the folder is empty and only to move 999 at a time.
 
it works great except when it sees files with duplicate names it bombs out while moving them.
i'd like it to rename the dup(maybe add some random #'s or characters to the end) and continune moving all the files.
 
I think I have to use "FileExists" method and "Select...Case" but I'm not sure how.
 
Was wondering if anyone could help me with this.
 
Here is the code-
 
 

source="H:\tempxtender"
target="c:\inetpub\mailroot\drop\"

Set fso = CreateObject("Scripting.FileSystemObject")
set root=fso.getFolder(source)
set targ=fso.getFolder(target)

dim full

do
 if targ.files.count=0 then full=false
 if full=false then call folderlist(root)
 wscript.sleep 1000
loop

sub folderlist(grp)
 call filelist(grp)
 if full then exit sub
 for each fldr in grp.subFolders
  set nf=fso.GetFolder(fldr.path)
  call folderlist(nf)
  set nf=nothing
 next
end sub

 sub filelist(grp)
 for each file in grp.files
  if targ.files.count>=999 then full=true:exit for
   if lcase(fso.getextensionname) = "eml" then file.move target
 next
 end sub

 

 

My aologies for bugging you guys with this OT.

 

Thanks

 

Reply via email to