标题: [系统相关] 批处理获取移动硬盘的剩余容量和总容量? [打印本页]
作者: shuaige100 时间: 2010-6-22 12:30 标题: 批处理获取移动硬盘的剩余容量和总容量?
要求1;fat fat32 ntfs的格式的盘都可以获取
2;同时显示剩余容量和总容量,多余盘多余的东西都不要显示
3;以m为单位显示,m后面的字节要省略,越简洁越好,我觉得用乘除来算mb太多余
5;8秒钟自动关闭
[ 本帖最后由 shuaige100 于 2010-6-23 17:12 编辑 ]
作者: shuaige100 时间: 2010-6-22 20:04
没人知道吗?百度搜的老长呢,感觉太复杂了
[ 本帖最后由 shuaige100 于 2010-6-22 22:24 编辑 ]
作者: Batcher 时间: 2010-6-22 20:56
- fsutil volume diskfree I:
复制代码
作者: Batcher 时间: 2010-6-22 21:05
批处理实现磁盘空间字节转MB的几个例子- @echo off
- setlocal enabledelayedexpansion
- set /a num2=1024*1024
- set total=0
- for %%i in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
- set num1=0
- set num3_str=
- set num4=
- for /f "tokens=3" %%j in ('dir /-c %%i:\ 2^>nul') do (
- set num1=%%j
- )
- if not "!num1!"=="0" (
- call :loop
- for /f "delims=0 tokens=*" %%k in ("!num3_str!") do (
- set num3_str=%%k
- )
- echo.
- echo %%i 盘剩余空间为 !num3_str! MB
- set /a total+=!num3_str!
- echo.
- )
- )
- echo 剩余空间总量为 !total! MB
- pause
- goto :eof
-
- :loop
- :: 求商
- set /a num3=%num4%%num1:~0,1%/%num2%
- :: 求商序列
- set num3_str=%num3_str%%num3%
- :: 求余
- set /a num4=%num4%%num1:~0,1%%%%num2%
- if %num4% equ 0 (
- set num4=
- )
- set num1=%num1:~1%
- if not "%num1%"=="" (
- goto :loop
- )
- goto :eof
复制代码
- @echo off
- setlocal enabledelayedexpansion
-
- >tmp.vbs echo result = wscript.arguments(1)/1024/1024
- >>tmp.vbs echo Wscript.Echo wscript.arguments(0),"盘剩余空间为",result,"MB"
-
- for %%i in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
- if exist %%i:\ (
- for /f "tokens=3" %%j in ('dir /-c %%i:\') do set num=%%j
- if not "%%j"=="0" cscript //nologo tmp.vbs %%i: !num!
- ))
- del tmp.vbs
- pause
- exit
复制代码
- @echo off
- >tmp.vbs echo result = wscript.arguments(1)/1024/1024
- >>tmp.vbs echo Wscript.Echo wscript.arguments(0),"盘剩余空间为",result,"MB"
-
- for %%i in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
- if exist %%i:\ (
- for /f "tokens=3" %%j in ('dir /-c %%i:\') do set num=%%j
- if not "%%j"=="0" call :loop %%i:
- ))
- del tmp.vbs
- pause
- exit
-
- :loop
- cscript //nologo tmp.vbs %1 %num%
- goto :eof
复制代码
- set fs = CreateObject("Scripting.FileSystemObject")
- set drivecollection = fs.Drives
- for each drive in drivecollection
- set drivec = fs.GetDrive(drive.path)
- emptyspace = drivec.AvailableSpace
- list=list & "Available on " & drive.path & vbtab&FormatNumber(emptyspace/1024^2,1) & "MB" & vbcr
- next
- msgbox list
复制代码
作者: pdanniel66 时间: 2010-6-23 06:58
楼主的Title不利于识别与搜寻,建议更改!
作者: shuaige100 时间: 2010-6-23 16:53 标题: 回复 4楼 的帖子
对不起管理员,以前的该题都表达不好,还有你的回答都不行的都没有显示的,我修改了移动硬盘为i盘,用不了啊
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |