[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[系统相关] 批处理获取移动硬盘的剩余容量和总容量?

要求1;fat fat32 ntfs的格式的盘都可以获取
2;同时显示剩余容量和总容量,多余盘多余的东西都不要显示
3;以m为单位显示,m后面的字节要省略,越简洁越好,我觉得用乘除来算mb太多余
5;8秒钟自动关闭

[ 本帖最后由 shuaige100 于 2010-6-23 17:12 编辑 ]
1

评分人数

    • Batcher: 问题解决后请不要大肆修改提问帖 http://b ...PB -10

没人知道吗?百度搜的老长呢,感觉太复杂了

[ 本帖最后由 shuaige100 于 2010-6-22 22:24 编辑 ]

TOP

  1. fsutil volume diskfree I:
复制代码
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

批处理实现磁盘空间字节转MB的几个例子
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. set /a num2=1024*1024
  4. set total=0
  5. 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 (
  6.     set num1=0
  7.     set num3_str=
  8.     set num4=
  9.     for /f "tokens=3" %%j in ('dir /-c %%i:\ 2^>nul') do (
  10.         set num1=%%j
  11.     )
  12.     if not "!num1!"=="0" (
  13.         call :loop
  14.         for /f "delims=0 tokens=*" %%k in ("!num3_str!") do (
  15.             set num3_str=%%k
  16.         )
  17.         echo.
  18.         echo %%i 盘剩余空间为 !num3_str! MB
  19.         set /a total+=!num3_str!
  20.         echo.
  21.     )
  22. )
  23. echo 剩余空间总量为 !total! MB
  24. pause
  25. goto :eof
  26. :loop
  27. :: 求商
  28. set /a num3=%num4%%num1:~0,1%/%num2%
  29. :: 求商序列
  30. set num3_str=%num3_str%%num3%
  31. :: 求余
  32. set /a num4=%num4%%num1:~0,1%%%%num2%
  33. if %num4% equ 0 (
  34.     set num4=
  35. )
  36. set num1=%num1:~1%
  37. if not "%num1%"=="" (
  38.     goto :loop
  39. )
  40. goto :eof
复制代码
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. >tmp.vbs echo result = wscript.arguments(1)/1024/1024
  4. >>tmp.vbs echo Wscript.Echo wscript.arguments(0),"盘剩余空间为",result,"MB"
  5. 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 (
  6.     if exist %%i:\ (
  7.         for /f "tokens=3" %%j in ('dir /-c %%i:\') do set num=%%j
  8.     if not "%%j"=="0" cscript //nologo tmp.vbs %%i: !num!
  9. ))
  10. del tmp.vbs
  11. pause
  12. exit
复制代码
  1. @echo off
  2. >tmp.vbs echo result = wscript.arguments(1)/1024/1024
  3. >>tmp.vbs echo Wscript.Echo wscript.arguments(0),"盘剩余空间为",result,"MB"
  4. 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 (
  5.     if exist %%i:\ (
  6.         for /f "tokens=3" %%j in ('dir /-c %%i:\') do set num=%%j
  7.     if not "%%j"=="0" call :loop %%i:
  8. ))
  9. del tmp.vbs
  10. pause
  11. exit
  12. :loop
  13. cscript //nologo tmp.vbs %1 %num%
  14. goto :eof
复制代码
  1. set fs = CreateObject("Scripting.FileSystemObject")
  2. set drivecollection = fs.Drives
  3. for each drive in drivecollection
  4. set drivec = fs.GetDrive(drive.path)
  5. emptyspace = drivec.AvailableSpace
  6. list=list & "Available on " & drive.path & vbtab&FormatNumber(emptyspace/1024^2,1) & "MB" & vbcr
  7. next
  8. msgbox list
复制代码
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

楼主的Title不利于识别与搜寻,建议更改!

TOP

回复 4楼 的帖子

对不起管理员,以前的该题都表达不好,还有你的回答都不行的都没有显示的,我修改了移动硬盘为i盘,用不了啊

TOP

返回列表