getExtensionName() requires you to pass it a filespec (a filename, or path to a file)

 

If FSO.getExtensionName(“c:\windows\clock.avi”) = “avi” Then

            ‘ do foo

Else

            ‘ do bar

End If

 

Cheers
Ken

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Kern
Sent: Thursday, 8 December 2005 1:48 PM
To: [email protected]
Subject: Re: [ActiveDir] _vbscript_ help(OT)

 

Oops, I guess i didn't check my code.

 

before i made any changes, i get "Wrong number of arguments or invalid propery assignment:'fso.getextensionname'.

 

sorry.

I wonder why that is?

 

On 12/7/05, Ken Schaefer <[EMAIL PROTECTED]> wrote:

At the moment you have this line which does the copy:

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

So, instead of doing the copy, check to see if the file exists at the target,
and if not do the copy. If it does exist, rename the file at the source, then
do the copy.

If LCase(FSO.getExtensionName ) = "eml" Then

       If objTarg.FileExists(strSourceFileName) Then

               ' Rename Source File

       End If

       ' Now do the copy

End If

Cheers
Ken


________________________________________
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] ] On Behalf Of Tom Kern
Sent: Thursday, 8 December 2005 12:00 PM
To: [email protected]
Subject: Re: [ActiveDir] _vbscript_ help(OT)

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:
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.

Thanks,
Brian Desmond
[EMAIL PROTECTED]

c - 312.731.3132


________________________________________
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 tomove 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 movingall thefiles.

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


List info   : http://www.activedir.org/List.aspx
List FAQ    : http://www.activedir.org/ListFAQ.aspx
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

 

Reply via email to