vbs Size 属性使用介绍(获取文件大小),vbssize
vbs Size 属性使用介绍(获取文件大小),vbssize
为大家介绍vbs属性之size属性,供大家学习参考。
Size 属性
对于文件,返回指定文件的字节数;对于文件夹,返回该文件夹中所有文件和子文件夹的字节数。方便我们判断文件的大小。
说明
object.Size
object 应为 File 或 Folder 对象的名称。
Folder 对象的 Size 属性示例:
Function ShowFolderSize(filespec)
Dim fso, f, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(filespec)
s = UCase(f.Name) & " 大小为 " & f.size & " 字节。"
ShowFolderSize = s
End Function
On Error Resume Next
Dim sourcepath
Dim numb
Sub fileW '写文件
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\2.txt", True)
MyFile.WriteLine("YES")
MyFile.Close
Set MyFile = fso.GetFile("c:\2.txt")
'MyFile.Delete
End Sub
Sub FolderAttributes(sourcepath)
Dim fso, objFile
Set fso = CreateObject("Scripting.FileSystemObject")
'调用GetFile()返回File对象,通过File对象来访问其下的属性
Set objFile = fso.GetFile(sourcepath)
MsgBox "文件大小:" & objFile.Size
if objfile.Size >= 100000 Then '文件大小需要准确判断请自己来定
MsgBox "YES"
fileW
Else
MsgBox "false"
End if
End Sub
sourcepath = "c:\1.txt"
Call FolderAttributes(sourcepath)
参考资料:自己写的有问题留言!
@echo off
setlocal enabledelayedexpansion
>tmp.vbs echo On Error Resume Next
>>tmp.vbs echo Set jFile = CreateObject("WIA.ImageFile"):jFile.LoadFile WScript.Arguments(0):WScript.Echo "W="^&jFile.Width:WScript.Echo "H="^&jFile.Height
echo 提取文件属性...
if exist 文件信息.txt del 文件信息.txt
set folder=G:\123
for /f "delims=""" %%i in ('dir /a-d /b /s %folder%') do (
for /f "tokens=1,2" %%j in ('dir /tc "%%i" ^| findstr "%%~nxi"') do (
set W=0&set H=0
echo.>>文件信息.txt
echo 文件名称:%%~nxi>>文件信息.txt
echo 文件大小:%%~zi字节>>文件信息.txt
echo 文件所在路径:%%~dpi>>文件信息.txt
echo 创建时间:%%j %%k>>文件信息.txt
echo 修改时间:%%~ti>>文件信息.txt
for /f "delims=" %%a in ('cscript.exe //nologo tmp.vbs "%%i"') do set "%%a"
if !W! gtr 0 echo 图片宽:!W!>>文件信息.txt
if !H! gtr 0 echo 图片高:!H!>>文件信息.txt
echo.>>文件信息.txt))
start "" notepad 文件信息.txt
del tmp.vbs
真搞不懂问你什么运行环境,居然不回答~
windows xp需要Windows Image Acquisition Automation Library v2.0库,百度不能贴地址的自己搜索一下
下载好WIAAutSDK.zip后运行一下RegSvr32 WIAAut.dll注册dll
参考资料:www.microsoft.com/...=18287
评论关闭