我正在尝试在当前目录的所有子文件夹中运行vbscript。 到目前为止,我有:
CreateObject("Wscript.Shell").Run("""*\dirlistnew.vbs""")
但这并不奏效。如果我删除*\
它将在当前目录中工作,但不在子目录中工作。我知道我错过了一些简单的事情。一直在搜索和尝试几个小时无济于事。
答案 0 :(得分:0)
从我的代码库中获取此信息,根据您的需要进行调整。 未经测试,我在过去几年里更多地使用Ruby。
'call our sub with the desired path as option
' this needs to be a Folder object, not a String
' FSO.GetFolder will return that object given a path as string
ShowSubfolders FSO.GetFolder(path)
Sub CreateHtml(path)
' put here the code from your other script (best)
' or do your call to execute the other script
' you probably need the path so you pass it as a parameter
End Sub
Sub ShowSubFolders(Folder)
' a Folder has the method SubFolders,
' gives a collection of subfolders that can be enumerated
' with For Each construct
For Each Subfolder in Folder.SubFolders
' print the subfolder so you can follow the progress
Wscript.Echo Subfolder.Path
' and call the sub that creates the html file
CreateHtml Subfolder.Path
' here the magic of recursion, the sub is calling itself with
' as parameter the subfolder to process the subsubfolders etc
ShowSubFolders Subfolder
Next
End Sub
在Ruby中注意它只有一行Dir["#{folder}/*"].each{|f| puts f if File.directory?(f) }