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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Files using Filenames in a table 1

Status
Not open for further replies.

Elysynn

Technical User
Mar 18, 2004
82
US
Hi, I have a challenge that I am hoping you can help with. I need to copy 200 .wav files from a few different servers in to one directory. There are multiple thousands of .wav files in the directories, else I would just copy and paste them manually.

The names of the .wav files and their path names are stored in a table - I just need to know how to use that information and initiate the copy process. I know this is a lot to ask... any direction is appreciated.

Thanks,
Elysynn
 
My initial thought would be that you could work in the Explorer Shell or FileSystem Object to do all what you need to do. The only thing that might make it difficult would be if there are any particular security settings you need to get through on each server. If you already have the paths for each file, and the destination of where you want them to be, it shouldn't be a problem.
 

Use a recordset to retrieve all the info form the table. Loop throu the records and use the FileCopy Statement to copy them
 
Thank you both for your input. It gave me the nudge in the right direction that I needed. Below is the code I implemented...

Code:
Public Function CopyCalls()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strSource As String
Dim strDestination As String
Dim strCallPath As String
Dim strCallDest As String
Dim strCallName As String

Set db = CurrentDb

strCallDest = "C:\Calls\"
strSQL = "SELECT * FROM tblCallExport;"
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)

rs.MoveLast
rs.MoveFirst

Do
strCallName = rs!tr_filename
strCallPath = rs!tr_path
strSource = strCallPath & "\" & strCallName
strDestination = strCallDest & strCallName
FileCopy strSource, strDestination
rs.MoveNext
Loop Until rs.EOF


Set rs = Nothing


End Function

Thanks again,
Elysynn
 
Elysynn

Nice work!

A tiny thing: you need, before the last line, an rs.Close

-------
I am happy to see a member, trying to manage his/her challenge and post-back a well formated solution!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top