Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy files that match a pattern in all subfolders

Status
Not open for further replies.

buddyel

MIS
Mar 3, 2002
279
US

Very simply, I would like to write a script that Copies all files that match the *_bak.mdb pattern in all subfolder under C:\Sessions to a location such as C:\SessionsBackup.

More advanced, I'd like to match the folder where the *_bak.mdb file was copied from to a matching folder in the SessionsBackup folder and would like to create a folder with todays date and copy the file there.

For example.
C:\Sessions\7600\7600_bak.mdb
Copied to
C:\SessionsBackup\7600\030606\7600_bak.mdb

Any help on accomplishing this or even just getting it started would be greatly appreciated.
 
This'll point you in the right direction for file searches.


This should point you in the right direction for file and folder manipulation. File System Object -

Here's your date format for the folder:
Code:
strDay = Day(Now)
strMonth = Month(Now)
strYear = Right(Year(Now),2)
If len(strDay) < 2 then strDay = "0" & strDay
if len(strMonth) < 2 then strMonth = "0" & strMonth
strDate = strMonth & strDay & strYear
 
I tried just copying the text in your first link and tried running it and got an error on line 2, char 1, error:: object required 'FSO'
 
this means you need to create an 'FSO' object.

Set FSO = CreateObject("Scripting.FileSystemObject")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top