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!

Count number of files in a folder 1

Status
Not open for further replies.

JonathonC

Technical User
Aug 18, 2001
43
GB
How can I count the number of files which have no file extension (the file dosen't have .something on the end of the file name) in a particular directory?

Thanks Jonathon. Computer problems? Have you checked the loose nut in front of the keyboard yet?
 
Option Explicit

Sub main()
Dim oFSO ' As Scripting.FileSystemObject
Dim oFolder ' As Scripting.Folder
Dim oFile ' As Scripting.File
Dim nCount As Long

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder("C:\")
For Each oFile In oFolder.Files
If oFSO.GetExtensionName(oFile.Name) = "" Then
nCount = nCount + 1
Debug.Print oFile.Name
End If
Next oFile

MsgBox nCount
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top