looping in a vba script to copy multiple files from one location to another

Hi, I have a vba script I need to modify to copy multiple files from a location  to another location...i am hoping the script below can be modified to loop to do this?...I have next to zero experience with vba.
The parameters will be got from a batch file which I will tackle as a seperate exercise.
Any guidance greatly appreciated.
on error resume next
'set up the environment
set oShell= CreateObject("Wscript.Shell")
set oEnv = oShell.Environment("PROCESS")

'get credentials from the command line params
uName = WScript.Arguments.Item
pwd= WScript.Arguments.Item

'get the urls from command line arguments
URL = WScript.Arguments.Item

'get the file save locations for each file from command line params

'set up the download jobs
dim xHttp: Set xHttp = createobject("MSXML2.ServerXMLHTTP.6.0") 
dim bStrm: Set bStrm = createobject("Adodb.Stream") 
xHttp.setTimeouts 5000,5000,5000,5000

'get first file
xHttp.Open "GET", URL, False, uName ,pwd
bStrm.type = 1 '//binary	
bStrm.write (xHttp.responseBody) 
if err=0 then bStrm.savetofile SaveLoc, 2 '//overwrite

'finall, clean up

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
Not sure that is a great script to start from, given your title of this question.

Can you expand on what files, and where, and how they are found, if they are in folders, on local machine, etc?

It sounded like you just need to copy some files from one location on a computer to another.  But this script is about getting files off of the internet, so doesn't seem write.

Also, how are you going to use this, you mentioned VBA, but the script you attached is not VBA, but rather VBS.  Slightly different and meant to be run from a command line rather than inside an Office Application like Excel.

Additional info will help us get you a solution.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
blossomparkAuthor Commented:
Hi Bill,
thanks for your response,
the files are in a folder on a windows  server and need to be copied to a diferent folder.... I'm not sure at this point if the different folder is on a different machine. I will clarify later.
thanks for the clarification re VBS, VBA , yes this will be run from a command line...
Bill PrewIT / Software Engineering ConsultantCommented:
Okay, tell me a little more about the files to be copied.  Will all the files be copied?  Are they in a single folder, or do subfolders need to be copied as well?  If the file exists in the destination should they be replaced?  Etc...

Also, why using VBS, this should be easily done right in the BAT script that it sounds like would be calling the VBS?

Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

blossomparkAuthor Commented:
All the files are in a single folder...I will need to check if there are other files in the folder that are NOT to be copied.
Why VBS?
I don't know, I inherited this situation.
Will the Bat script be calling the VBS script ? Yes
If it can all be done in a bat script then all the better
blossomparkAuthor Commented:
Hi Bill,
apologies for the vagueness of the information I supplied. I will try and get you some more relevant info and update at some point today, thank you
blossomparkAuthor Commented:
Hope the following answers your questions; please shout if you need more information.
The files to be copied are 13 xls files that reside in a single folder. All the files will be copied. These are the only files that will reside ion the source location.
If the files exist in the destination they should be replaced.
The source location is an internet location.
The destination location is a network location on a Windows Active Directory network.
The reason why a BAT file is not being used is I’m told for historical security and scheduling reasons
Bill PrewIT / Software Engineering ConsultantCommented:
The source location is an internet location.

Please clarify this further.  Does this present to Windows as a mapped drive?  Or is it a web page that has links to the files?  Or an FTP site?  Etc...

blossomparkAuthor Commented:
Hi Bill, thanks for your assistance on this, you have clarified a few things for me and I think its best I restart this with a new approach once I review, again thanks for your help and patience
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.