Solved

Error running VBS

Posted on 2011-09-20
3
265 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:epicazo
3 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 125 total points
ID: 36570370
Hi, change this:
fso.CreateFolder strTargetFolderA & strFirst8

to this:
fso.CreateFolder strTargetFolderA & "\" & strFirst8

Rob.
0
 
LVL 6

Expert Comment

by:jorgedeoliveiraborges
ID: 36583856
Put a new Line 11 in order to debug, please.
msgbox strTargetFolderA & strFirst8
0
 

Author Closing Comment

by:epicazo
ID: 36588898
thank you
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question