copy contents of root directory

  • Thread starter Thread starter NoodNutt
  • Start date Start date
N

NoodNutt

G'day ppl

Is there a process whereby I can copy the text labels of all the files in a
root directory?

I recall going back a long way seeing something about it but did not take
any notice as I didn't think I would ever use it.

TIA
Mark
 
NoodNutt said:
G'day ppl

Is there a process whereby I can copy the text labels of all the files in a
root directory?

I recall going back a long way seeing something about it but did not take
any notice as I didn't think I would ever use it.

If you're refering to file names there's

VBA.FileSystem.Dir()
or
the Scripting.Folder object's Files collection.
 
G'day & thx for the reply,

Both sound great, though I have absolutley no idea how to implement/initiate
either of them.

Can you please provide an example of how to structure the code please.

Thx again

Mark.
 
Here is a quickie sub showing how to use the Dir() function

Public Sub GetDirFilesNames(strStartDir)

Dim strFilename As String

strFilename = Dir(strStartDir)
Do While Len(strFilename) > 0
Debug.Print strFilename
strFilename = Dir
Loop
End Sub

You would call thhis sub with the full pathanme to the directory you want to
interrogate. For Example:

GetDirFilesNames "c:\"

All this routine does is to print all of the filenames in that directory to
the immediate window, but it should give you an idea how to structure your
code. If I were you and all I needed to do was to get a list of files for
one directory I would use this sort of structure. If you have to get all of
the files for an entire volume, and speed is an issue, then I would look to
implement the lower level functions FindFirst / FindNext.
 
G'day Ron & thx for replying.

I actually got the answer I needed via a couple of streams & eventually
ended up with this:

Private Sub Command20_Click()

Dim db As DAO.Database, rsFiles As DAO.Recordset, strName As String

Set db = CurrentDb()
Set rs = db.OpenRecordset("tblTrackInfo", dbOpenTable)


strName = Dir("c:\media\music\various\*.*")

Do While Len(strName) > 0
rs.AddNew
rs!SongTitle = strName
rs.Update

strName = Dir
Loop

End Sub

regards
Mark
 
Back
Top