批处理记录电脑磁盘剩余容量并输出到txt中

@echo off
setlocal EnableDelayedExpansion

echo -----------------------------记录时间:%date%%time% >>剩余容量.txt

(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: ^|find "可用字节"') do (

set space=%%j

set space=!space:~0,-3!

set /a space=!space!/1024/1024

for /f "tokens=3*" %%v in ('vol %%i:') do set volume=%%w

 

echo %%i:!volume! 剩余 !space! GB可用

)

))>>剩余容量.txt

exit

posted @ 2021-08-19 09:10  MRO物料采购服务  阅读(203)  评论(0编辑  收藏  举报