How do I import system file details such as filename and date etc.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,

Is there a way to import system file information, such as filename, modified
date, etc, into an Excel spreadsheet or Access database?

I have nearly 4,000 photographs I'm attempting to sort and catagorise, and
it would be very usefull to be able to gather this information into a
spreadsheet.

I know it can be done with Access, but how?

Thanks all,
Cheers!
 
Rooksie,

Try this piece of code on a blank worksheet:

Sub get_file_details()
Dim fs, f, f1, f2
Range("A1").Select
ActiveCell.Offset(0, 0).Value = "File name"
ActiveCell.Offset(0, 1).Value = "Created"
ActiveCell.Offset(0, 2).Value = "Modified"
i = 1
fldr = "C:\My Documents\My Pictures\"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.getfolder(fldr)
Set f1 = f.Files
For Each f2 In f1
If Right(f2.Name, 4) = ".jpg" Then
ActiveCell.Offset(i, 0).Value = f2.Name
ActiveCell.Offset(i, 1).Value = f2.DateCreated
ActiveCell.Offset(i, 2).Value = f2.DateLastModified
i = i + 1
End If
Next
End Sub

Just change the path and file extension, and it will work on anything.

The process in Access would be similar as far as the file attribute
retrieval goes, and would involve a recordset operation to write to a table.

HTH,
Nikos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top