Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I get an error if the directory is empty and it stops running 1

Status
Not open for further replies.

at1knowitall

Technical User
Sep 6, 2007
4
US
I get an error if any of the three directories are empty, is there a way to skip over the movefile if the directory is empty?

Thanks,
Mark

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile "\\whdb\new\*.*", "\\whdb\admin"
fso.MoveFile "\\whdb\new1\*.*", "\\whdb\admin"
fso.MoveFile "\\whdb\new2\*.*", "\\whdb\admin
 
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
fso.MoveFile "\\whdb\new\*.*", "\\whdb\admin"
fso.MoveFile "\\whdb\new1\*.*", "\\whdb\admin"
fso.MoveFile "\\whdb\new2\*.*", "\\whdb\admin"
On Error Goto 0

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
And here's another way, which can be modified to suit your needs:
Code:
Dim fso, f, iCount
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("\\whdb\new")
iCount = f.Files.Count
wscript.echo "Total files: " & iCount
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top