I don't see the need for a select case, but File.Exists would help.
What I would do is something like this
Dim moveName
moveName = CurrentNameOfFile
While TargetFolder.FileExists(currentNameofFile)
currentNameOfFile = currentNameofFile + Cstr(Int(Rnd * 10000))
Wend
'moveTheFile()
Rnd*1000 will get you some random # 0 – 1000 int makes it an integer and cstr makes it a string.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Tom Kern
Sent: Wednesday, December 07, 2005 7:01 PM
To: activedirectory
Subject: [ActiveDir] _vbscript_ help(OT)
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
loopsub 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 subsub 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
Thanks.
My real problem is, I'm not sure where to put that in my exisiting script without screwing things up....
Should that be a seperate sub?
Thanks again
On 12/7/05, Brian Desmond <[EMAIL PROTECTED]> wrote:
- [ActiveDir] VBScript help(OT) Tom Kern
- RE: [ActiveDir] VBScript help(OT) Brian Desmond
- Re: [ActiveDir] VBScript help(OT) Tom Kern
- RE: [ActiveDir] VBScript help(OT) Brian Desmond
- RE: [ActiveDir] VBScript help(OT) Ken Schaefer
- Re: [ActiveDir] VBScript help(OT) Tom Kern
- RE: [ActiveDir] VBScript help(OT) Ken Schaefer
- Re: [ActiveDir] VBScript help(OT) Tom Kern
- RE: [ActiveDir] VBScript help(OT) Rich Milburn
- Re: [ActiveDir] VBScript help(OT) Tom Kern
- Re: [ActiveDir] VBScript help(OT) Kamlesh Parmar
- RE: [ActiveDir] VBScript help(OT) Rich Milburn
- Re: [ActiveDir] VBScript help(OT) Tom Kern
