我是VBS和脚本的相对新手。我有一个管家脚本除了其他东西清除空文件夹,我有点麻烦,希望有人可以告诉我我哪里出错了..
这是我的潜艇
sub clearfolder(folder) 'Recursive search for old empty folders
For Each Subfolder in Folder.SubFolders
If Subfolder.Files.Count = 0 And Subfolder.SubFolders.Count = 0 Then
Logwrite "The folder:" & Subfolder.Path & " is empty and will be removed"
redim preserve arrFolders(arrpath)
arrFolders(arrpath) = Subfolder.Path
foldersDeleted = foldersDeleted + 1
arrpath = arrpath + 1
else
Logwrite "The folder:" & Subfolder.Path & " Contains files or folders"
End If
clearfolder Subfolder
Next
end sub
当我打电话给子..
这有效:
clearfolder objFSO.GetFolder ("F:\Scripts\file_cleardown\Testing\_UK")
这不起作用:(strVariable高于路径)
clearfolder objFSO.GetFolder (strVariable)
有人可以解释为什么我似乎无法传递包含路径而不是完整路径的变量吗?我已经尝试了各种方法将路径作为变量传递,但我通常得到以下错误。
---------------------------
Windows Script Host
---------------------------
Script: F:\Scripts\file_cleardown\bill_cleanup.vbs
Line: 70
Char: 2
Error: Object required: 'folder'
Code: 800A01A8
Source: Microsoft VBScript runtime error
---------------------------
OK
---------------------------
提前致谢!