2012-05-04 27 views
1

我需要开发donwload所有文件大小等于0,从驱动器C.我已经做了的VBScript脚本如下:如何让递归下载所有空文件的脚本?

Dim oFSO 
Dim sDirectoryPath 
Dim oFolder 
Dim oFileCollection 
Dim oFile 
Dim oFolderCollection 
Dim n 
Set oFSO = CreateObject("Scripting.FileSystemObject") 
sDirectoryPath = "C:\" 
set oFolder = oFSO.GetFolder(sDirectoryPath) 
set oFolderCollection = oFolder.SubFolders 
set oFileCollection = oFolder.Files 
For each oFile in oFileCollection 
    IF oFile.Size = 0 Then 
     oFile.Delete(true) 
    END IF 
Next  

但是这个剧本只从C盘的根目录下删除文件!我需要在此代码中使用recusrive,但我是VBScript中的新成员,并且不知道如何执行此操作。请,我希望你能帮助我。谢谢。

+1

什么是这样的:http://www.wisesoft.co.uk/scripts/vbscript_recursive_file_delete_by_extension.aspx – HK1

回答

0

这里进行测试和工作脚本

set oFso = createobject("scripting.filesystemobject") 
sDirectorypath = "c:\testing" 
delete_empty_files(sDirectorypath) 

sub delete_empty_files(folder) 
    set oFolder = oFso.getfolder(folder) 
    for each oFile in oFolder.files 
    if oFile.size = 0 then 
     wscript.echo " deleting " & oFile.path 
     oFile.delete(true) 
    end if 
    next 
    for each oSubFolder in oFolder.subfolders 
    delete_empty_files(oSubFolder) 
    next 
end sub 
相关问题