Solved

Error running VBS

Posted on 2011-09-20
3
263 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now