Import file size and file names from a directory

Z

zahid

I have a lot of pdf files in a directory.
I want to extract file names and file sizes in excel or access.
Can you advise me any tool or code to do above task.
Please also tell, If this can be done in Frontpage.
 
D

Don Guillett

try
Sub FindFiles()
mypath = "c:\a"
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = mypath
.SearchSubFolders = True 'False
.MatchTextExactly = False
.filename = ".xls"
If .Execute(msoSortOrderDescending) > 0 Then
'MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
If Mid(.FoundFiles(i), Len(mypath) + 1, 2) <> " " Then
Cells(i + lastrow, 1).Value = FileLen(.FoundFiles(i))
'Cells(i + lastrow, 2).Value = FileDateTime(.FoundFiles(i))
Cells(i + lastrow, 3).Value = Right(.FoundFiles(i), _
Len(.FoundFiles(i)) - Len(mypath) - 1)
End If
Next i
Else
MsgBox "There were no files found."
End If
End With
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
 
Top