Avatar of donnie91910
donnie91910
 asked on

"Expected end of statement" error in VBScript code.

I have written VBScript code to look for specific files in a folder and when the code finds the files the code will move the files to another folder.  I am able to find one file and move it, but when I try to find two or more files I get the "Expected end of statement" error.  I have included the code that I have written.  

Dim objFSO
Dim sSourceFolder
Dim sDestFolder
Dim sDBFile
Dim sDateTimeStamp
'Const OVER_WRITE_FILES = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
sSourceFolder = "C:\Oceanside\"
sBackupFolder = "C:\Files_Found\"
sDBFile = "ROWP19-0578 PERMIT","ROWP19-0579 PERMIT"  'Expected end of statement error on this line when I try to search for two files
sDBFileExt = "pdf"
 
'If the backup folder doesn't exist, create it.
If Not objFSO.FolderExists(sBackupFolder) Then
    objFSO.CreateFolder(sBackupFolder)
End If
 
'Copy the file as long as the file can be found
If objFSO.FileExists(sSourceFolder & "\" & sDBFile & "." & sDBFileExt) Then
    objFSO.CopyFile sSourceFolder & "\" & sDBFile & "." & sDBFileExt,_
			sBackupFolder & "\" & sDBFile & "." & sDBFileExt
MsgBox sSourceFolder & " was copied to " & sBackupFolder
End if
 
Set objFSO = Nothing

Open in new window

Any help is greatly appreciated.
VB Script

Avatar of undefined
Last Comment
donnie91910

8/22/2022 - Mon
Serge Fournier

You have to define an array:

sDBFile_arr = array("ROWP19-0578 PERMIT","ROWP19-0579 PERMIT" )

then loop each element in array

for each sdbfile in sdbfile_arr
'code
next
ASKER CERTIFIED SOLUTION
Ryan Chong

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
donnie91910

ASKER
The array code worked. Thanks to both of you.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23