Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21100

Count files in folders, subfolders on remote servers

$
0
0
Hi all, complete noob to vb.

OK.. so I have this. It does great at counting the number of files in c:\temp and it's subfolders. But it pops it up in a msgbox.

What I really need is something that will
a) read a list of remote computers (e.g., c:\servers.txt)
b) count the files in a folder (and subfolders) e.g., c:\temp
c)output all of this to a text file (output.txt) thusly

Server Number of Files
LukeSky 12
DarthV 9
HansSolo 27
PrincessL 4

etc etc.. here is what I'm starting with.. obviously, I don't know what I'm doing. Any help appreciated.



Code:

      Option Explicit
         
        dim fs, a
         
        Set fs = CreateObject("scripting.filesystemobject")
       
         
        ' count files in temp directory
        Msgbox CountFiles ("c:\temp")
         
       
        Function CountFiles (ByVal StrFolder)
            Dim ParentFld
            Dim SubFld
            Dim IntCount
         
            Set ParentFld = fs.GetFolder (StrFolder)
           
            IntCount = ParentFld.Files.Count
           
            For Each SubFld In ParentFld.SubFolders
       
                IntCount = IntCount + CountFiles(SubFld.Path)
            Next
         
            Countfiles = IntCount
        End Function


Viewing all articles
Browse latest Browse all 21100

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>