Hi!

I'm trying to find an answer to a question that I know has been answered many times over, but for all I can see all of the answers pertain to VBCode and not VBScripting. I would like to be able to have something that would return the number of files in a folder and all of its subfolders as an Integer. I have seen solutions to this in VB using list boxes and Dir() Etc, but none of these apply to a simple script that has no interface. Can anyone give me any ideas ? :/

I am doing a loop that goes through a folder and deletes all of the files, and counts them, then a second loop after that that goes through a folder and deletes any subdirectories that are there but I have no way of counting those files, because I cannot set the actual pathname of the subdirectory.

Here is my code so far (Second Loop):

VB Code:
  1. LogStream.WriteLine(LogStamp & "------Lab" & pathVar & " Begin Document Folder Cleaning")
  2.         mydocsSubFolderCount = 0
  3.         For Each mydocsSubFolder in mydocsFolder.SubFolders
  4.             If DateDiff("h", mydocsSubFolder.DateLastModified, now) > 24 Then
  5.                 mydocsSubFolderFiles = mydocsSubFolderFiles + mydocsSubFolder.Files.Count
  6.                 LogStream.WriteLine(LogStamp & mydocsFolder.Files.Count)
  7.                 mydocsSubFolder.Delete
  8.                 mydocsSubFolderCount = mydocsSubFolderCount + 1
  9.             End If
  10.         Next
  11.         LogStream.WriteLine(LogStamp & "------Lab" & pathVar & " " & mydocsSubFolderCount & " Document Folders Deleted")
  12.         LogStream.WriteLine(LogStamp & mydocsSubFolderFiles)
  13.         LogStream.WriteLine(LogStamp & "*")

My problem is that the .SubFolders object doesnt support the .Files.Count method.

Please help! Any sort of outside function would work if needed, I just need to get a number as an Integer.