Link to home
Start Free TrialLog in
Avatar of epicazo
epicazoFlag for United States of America

asked on

Error running VBS

I am trying to copy files to FolderA then move them to FolderB, but I get an VBScript error:




LINE 11
CHAR: 9
ERROR: Bad File name or number
Code 800A0034

See CODE BELOW...

strSourceFolder = "\\10.41.40.119\ercharts$"
strTargetFolderA = "\\10.41.40.119\ercharts$"
strTargetFolderB = "\\10.41.32.139\rootsftp$\MarinaMBS"

If Right(strSourceFolder, 1) <> "\" Then strSourceFolder = strSourceFolder & "\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set objSource = fso.GetFolder(strSourceFolder)
For Each oFile In objSource.Files
    strFirst8 = Left(oFile.Name, 8)
    If Not fso.FolderExists(strTargetFolderA & strFirst8) Then
        fso.CreateFolder strTargetFolderA & strFirst8
    End If
    fso.copyfile strSourceFolder & oFile.Name, strTargetFolderA & strFirst8 & "\"
    fso.MoveFile strSourceFolder & oFile.Name, strTargetFolderB & strFirst8 & "\"
Next

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Put a new Line 11 in order to debug, please.
msgbox strTargetFolderA & strFirst8
Avatar of epicazo

ASKER

thank you