/    Sign up×
Community /Pin to ProfileBookmark

More efficient way to do a file count??

I use this code to get a file count recursively on a folder is the a more efficient way of doing this??

<%
Dim cnt

Sub Recurse(Path)

Dim fso, Root, WindowsFolder, Files, Folders, File, i, FoldersArray(10000)

Set fso = Server.CreateObject(“Scripting.FileSystemObject”)
Set Root = fso.getfolder(Path)
Set Files = Root.Files
Set Folders = Root.SubFolders
Server.ScriptTimeout = 10000

For Each Folder In Folders

Dim objFSO, objFolder

Set objFSO=Server.CreateObject(“Scripting.FileSystemObject”)
Set objFolder=objFSO.GetFolder(Folder.Path)
cnt = cnt + objFolder.files.Count
Set objFolder = Nothing
Set objFSO = Nothing
FoldersArray(i) = Folder.Path
i = i + 1
Next

For i = 0 To UBound(FoldersArray)
if FoldersArray(i) <> “” Then
Recurse FoldersArray(i)
Else
Exit For
End if
Next

End Sub

Recurse “D:Folder to Count”

%>

Thanks
Dr5150ut

to post a comment

0Be the first to comment 😎

×

Success!

Help @Dr_5150 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...