Re: Count Files and Folders



Hey thanks very much!

I hacked the script a little to also include the total number of folders,
which I also needed:

Dim totFileCount, totFolderCount
Set fs = CreateObject("Scripting.FileSystemObject")
startFolder = "C:\"

totFileCount = fs.GetFolder(startFolder).Files.Count
CountSubfolderFiles fs.GetFolder(startFolder)
CountSubfolderFolders fs.GetFolder(startFolder)
Wscript.echo "TOTAL FILES = ", totFileCount
Wscript.echo "TOTAL FOLDERS = ", totFolderCount
Wscript.Quit

Sub CountSubfolderFiles(Folder)
For Each Subfolder in Folder.SubFolders
totFileCount = totFileCount + SubFolder.Files.Count
CountSubfolderFiles Subfolder
Next
End Sub

Sub CountSubfolderFolders(Folder)
For Each Subfolder in Folder.SubFolders
WScript.Echo Folder.Path
totFolderCount = totFolderCount + 1
CountSubfolderFolders Subfolder
Next
End Sub

"Ato Bisda" <atobisda@xxxxxxxxx> wrote in message
news:e1LlVtfbFHA.2984@xxxxxxxxxxxxxxxxxxxxxxx
> http://forums.techarena.in/archive/index.php/t-77893.html
>
> "ServerMonkey" <anonymous@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:42a9f535$1@xxxxxxxxxxxxxxxxxxxxxx
> > This should be really easy, but can't seem to do it. I'm needing a
script
> > that counts the number of files and folders on a local disk.
> >
> >
>
>


.



Relevant Pages

  • Re: CLean out all users Temp Dir Folder
    ... I've built the script you need with ScriptAhead a tool we have just ... ' Get Folders that match the following criteria: ... Sub AppendCollectionToArray ... GetSubFolders strFolderName ...
    (microsoft.public.windows.server.scripting)
  • Re: Archive Message Folder Script by Jolly Roger
    ... inside each of those root folders is a multitude of sub folders. ... Now I have run the script a number of times and it makes it through ...
    (microsoft.public.mac.office.entourage)
  • Re: Path not found error using FSO GetFolder
    ... Sub ShowSubFolders ... For Each Subfolder in Folder.SubFolders 'Path Not Found error on ... This is just a test script for part of another project where I need to ... list files in folders, however, I need to ignore folders that can't be ...
    (microsoft.public.scripting.vbscript)
  • Re: Path not found error using FSO GetFolder
    ... Sub ShowSubFolders ... For Each Subfolder in Folder.SubFolders 'Path Not Found error on this ... This is just a test script for part of another project where I need to list ... files in folders, however, I need to ignore folders that can't be accessed ...
    (microsoft.public.scripting.vbscript)
  • Re: Detecting is hyperthreading is enabled with WMI?
    ... It is too bad that WMI does not give this info. ... have to be done to the script. ... Public Sub DisplayProcessorInfo ... dim ProcessorSet, Processor ...
    (microsoft.public.windowsxp.wmi)