troubleshooting Question

Vb Script- Error in CopyFile Method using wildcard

Avatar of Clement P
Clement PFlag for United Kingdom of Great Britain and Northern Ireland asked on
VB Script
11 Comments1 Solution742 ViewsLast Modified:
Hi experts,

I am getting the error msg "Path not found, Code: 800A004C" while running the attached VB script

Dim arrFileLines()
i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("D:\ScannerTesting\Watch Directory\scanned no\scanner.txt", 1)
Do Until objFile.AtEndOfStream
     Redim Preserve arrFileLines(i)
     arrFileLines(i) = objFile.ReadLine
     i = i + 1
Loop
objFile.Close
For l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "D:\ScannerTesting\Watch Directory\Images\*.jpg","L:\" &arrFileLines(l) & ".jpg",False


Msgbox arrFileLines(l)
Next


What I am trying to do over here is copy the image (there is only one image file) from the directory "D:\ScannerTesting\Watch Directory\Images\" and paste it some where else and change the name of the file. The name of the image file in "D:\ScannerTesting\Watch Directory\Images\" is constantly changing, that is why, I am using the wildcard feature

The sript works fine if I hard code the name of the image file to be copied..however it gives me error mentioned above when I am using a wildcard.

Can you please tell me where I am getting it wrong as I got the syntax to use the wilcard from microsoft msdn site

http://msdn.microsoft.com/en-us/library/e1wf9e7w(VS.85).aspx


Thanks in advance
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros