Hi
I have two machines that syncs a specific folder with each other - but only the "visible" files are synced!
I've found and edited the following script that counts all files in a directory, and it works - but it counts all files including system files and hidden files! How do I exclude these?
I would also like the script to count the folders.
In this way I can check if the folders contain the same amount of files and folders!
Hope you guys can help me :)
I have two machines that syncs a specific folder with each other - but only the "visible" files are synced!
I've found and edited the following script that counts all files in a directory, and it works - but it counts all files including system files and hidden files! How do I exclude these?
I would also like the script to count the folders.
In this way I can check if the folders contain the same amount of files and folders!
Code:
' VBScript
Option Explicit
Dim fs ' variable declared outside a procedure (this is a global variable)
' this is hold a reference to the file system object
' create an instance
Set fs = CreateObject("scripting.filesystemobject")
' count files in windows directory
Dim CountFilesResult
CountFilesResult = CountFiles ("C:\Testing")
' takes a string argument containing the name of the directory
' returns an integer contiang the nubmer of files in that direcrectory
' and all sub directories
Function CountFiles (ByVal StrFolder)
Dim ParentFld
Dim SubFld
Dim IntCount
' note the use of the fs global variable
Set ParentFld = fs.GetFolder (StrFolder)
' count the number of files in the current directory
IntCount = ParentFld.Files.Count
For Each SubFld In ParentFld.SubFolders
' count all files in each subfolder - recursion point
IntCount = IntCount + CountFiles(SubFld.Path)
Next
' return counted files
CountFiles = IntCount
End Function