VBScript遍历子文件夹中的目录 [英] VBScript to loop through directories within a subfolder
问题描述
你好!
首先,我想对我寻求帮助感到抱歉,通常我会自己处理这些问题,但是由于我是VBS的新手,所以这对我来说很痛苦!
好的,我为一家拥有DFSshare的公司工作,当共享空间为空时,我们遇到了问题.
我必须制作一个VBScript来查找空文件夹.
"RootFolder"> 这里有很多代表客户的文件夹" 此文件夹不能为空"
这就是我所走的路,但是它所做的只是让我瞥见了):
Hi there !
First off I''d like to say I''m sorry for asking for help, normally I would deal with this stuff myself, but since I''m all new to VBS this has been a pain for me !
Okay, I work for a company with a DFSshare and we have had problems when the share looks empty.
I have to make a VBScript to look for empty folders.
"RootFolder" > "A lot of folders in here representing customers" > "This folder cannot be empty"
This is how far I got, but all it does is give me a glimps ):
Set FSO = CreateObject("Scripting.FileSystemObject")
'Define Root folder
ShowSubfolders FSO.GetFolder("C:\DFSRoots")
Sub ShowSubFolders(Folder)
'For Each folder, create another For Each instance
For Each Subfolder in Folder.SubFolders
For Each subdir in Subfolder.SubFolders
'Create Status to contain the result
Status = 0
'Grab path of the folder to check for empty...ness
set folder = FSO.GetFolder(subdir.Path)
'If subdir.Path contains no files, nor folders throw Status 2, otherwise Status 0
If folder.Files.Count + folder.SubFolders.Count = 0 Then
Status = 2
WScript.Echo Status
Else
Status = 0
WScript.Echo Status
End If
Next
Next
End Sub
完整的代码片段会很棒,但是在正确方向上的智慧也是可以的:)
谢谢!
It would be awesome with a whole code snippet, but a wift in the right direction is also okay :)
Thanks !
推荐答案
似乎递归 [ Uwe
Seems that the recursion [^] is missing in your method?
Cheers
Uwe
这篇关于VBScript遍历子文件夹中的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!