China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-03 08:35
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Request for a batch file to detect remaining disk space View 1,054 Replies 1
Original Poster Posted 2007-02-02 06:54 ·  中国 浙江 电信
中级用户
★★
Credits 385
Posts 156
Joined 2007-01-19 02:32
19-year member
UID 76955
Gender Male
Status Offline
Start checking from the first drive for its free space. If the free space is greater than 2048M, stop checking and create a directory on that drive.

[ Last edited by heicai on 2007-2-1 at 08:41 PM ]
Floor 2 Posted 2007-02-02 07:12 ·  中国 浙江 电信
中级用户
★★
Credits 385
Posts 156
Joined 2007-01-19 02:32
19-year member
UID 76955
Gender Male
Status Offline
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

for %%a 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 %%a:\nul (
for /f "tokens=3" %%b in ('dir /-c %%a:\^|find "可用字节"') do set freesize=%%b
set /a freesize=!freesize:~0,-3!/1049>nul
if !freesize! GTR ^18000 (md %%a:\Temp & goto exit)
)
echo %%a has less than 18G, continue checking the next disk
pause
)
:exit
echo Task completed, press any key to exit
pause
exit


I don't know whether there are any problems with the code. Please check whether it's rigorous enough.

[ Last edited by heicai on 2007-2-1 at 08:57 PM ]
Forum Jump: