如何制作递归下载所有空文件的脚本? [英] How can I make script for recursive downloading all empty files?
本文介绍了如何制作递归下载所有空文件的脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要开发从驱动器 C 下载大小等于 0 的所有文件的 VBScript.我制作了以下脚本:
I need to develop the VBScript that donwload all files with size equals 0 from drive C. I have made following script:
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 的新手,不知道该怎么做.拜托,我希望你能帮助我.谢谢.
But this script deletes files from root directory of drive C only! I need to use recusrive in this code, but I'm new in VBScript and don't know how I can do it. Please, I hope you will help me. Thank you.
推荐答案
这里是一个经过测试且有效的脚本
here a tested and working script
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
这篇关于如何制作递归下载所有空文件的脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文