获得文件夹大小的vbs代码
2016-06-29来源:

这篇文章主要介绍了vbs中获得文件夹大小的代码,需要的朋友可以参考下

代码如下:

'----------------------

'获得文件夹的大小

'author = baiyang

'version = 1.0

'date = 09.08.08

'----------------------

option explicit

on error resume next

dim objfso, objlocalfolder, strarg, longlocalfoldersize, strsizemess

'判断是不是没有路径参数

if wscript.arguments.count < 1 then

wscript.echo 参数无效, 第一个参数为路径

wscript.quit

else

strarg = wscript.arguments(0)

end if

set objfso = createobject(scripting.filesystemobject)

set objlocalfolder = objfso.getfolder(strarg)

if objlocalfolder = empty then

wscript.echo invalid path

wscript.quit

end if

longlocalfoldersize = objlocalfolder.size

if longlocalfoldersize>=1024 and longlocalfoldersize<1024*1024 then

strsizemess = round( longlocalfoldersize/1024, 3 ) & k

elseif longlocalfoldersize>=1024*1024 and longlocalfoldersize<1024*1024*1024 then

strsizemess = round( longlocalfoldersize/1024/1024, 3 ) & m

elseif longlocalfoldersize>=1024*1024*1024 then

strsizemess = round( longlocalfoldersize/1024/1024/1024, 3 ) & g

else

strsizemess = longlocalfoldersize & b

end if

wscript.echo strsizemess

set objfso = nothing

set objlocalfolder = nothing

wscript.quit

使用方法:

将上面的挨骂保存文件为: getflodersize.vbs

用法: getflodersize.vbs c:\windows即可。

推荐信息
Baidu
map