-
Apr 29th, 2004, 03:05 PM
#1
Thread Starter
Junior Member
Count Files in Folder & Subfolders, have searched to no avail!
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:
LogStream.WriteLine(LogStamp & "------Lab" & pathVar & " Begin Document Folder Cleaning")
mydocsSubFolderCount = 0
For Each mydocsSubFolder in mydocsFolder.SubFolders
If DateDiff("h", mydocsSubFolder.DateLastModified, now) > 24 Then
mydocsSubFolderFiles = mydocsSubFolderFiles + mydocsSubFolder.Files.Count
LogStream.WriteLine(LogStamp & mydocsFolder.Files.Count)
mydocsSubFolder.Delete
mydocsSubFolderCount = mydocsSubFolderCount + 1
End If
Next
LogStream.WriteLine(LogStamp & "------Lab" & pathVar & " " & mydocsSubFolderCount & " Document Folders Deleted")
LogStream.WriteLine(LogStamp & mydocsSubFolderFiles)
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|