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-06-24 14:53
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to determine if the free space on drive D is greater than 1GB? View 2,324 Replies 7
Original Poster Posted 2006-12-13 03:12 ·  中国 广东 深圳 电信
初级用户
Credits 43
Posts 14
Joined 2006-12-09 06:08
19-year member
UID 73009
Gender Male
Status Offline
Please: How to determine if the free space on drive D is greater than 1GB? Thank you.
Floor 2 Posted 2006-12-13 03:34 ·  中国 广东 深圳 电信
初级用户
Credits 43
Posts 14
Joined 2006-12-09 06:08
19-year member
UID 73009
Gender Male
Status Offline
Supplement: It needs to run normally under pure DOS, thank you.
Floor 3 Posted 2006-12-18 15:25 ·  中国 广东 深圳 电信
新手上路
Credits 6
Posts 2
Joined 2006-11-18 07:07
19-year member
UID 70933
Gender Male
Status Offline
@ECHO OFF
setlocal EnableDelayedExpansion
for /f "tokens=3" %%i in ('dir /-c D:\') do set freesize=%%i
set /a freesize=!freesize:~0,-6!/1024>nul
ECHO %freesize%
set /a baseCapacity=1
PAUSE
IF %freesize% GTR %baseCapacity% goto gtr
ECHO The space is less than %baseCapacity%G
pause
exit
:gtr
ECHO The space is greater than %baseCapacity%G
pause

[ Last edited by yusir0710 on 2006-12-18 at 02:37 AM ]
Floor 4 Posted 2006-12-18 22:32 ·  中国 江苏 苏州 联通
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
The one upstairs is for use under CMD, and it can't be used in pure DOS. I haven't thought of how to judge in pure DOS for the time being.
Floor 5 Posted 2006-12-19 02:38 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
This is interesting~:)
I wonder if Brother mp3down has found out what method they used in some tools like one-click recovery disks?

Assembly... Function call 36H can obtain the free disk space, and then operate Debug with the prompt method to directly write assembly code, so that no temporary files can be generated.

(Another: The above method can be realized without calling third-party tools)
(Then continue to directly compare in Debug whether it is greater than 1G or less than 1G, call 4CH DOS function to return a flag number to ERRORLEVEL, and the batch processing will judge)
(Theoretically completely achievable)

The above is just a suggestion for you, I can't code~:)
Brother can post to the "DOS Development Programming & Development Exchange (Development Room)" in the forum to ask what the principle code of directly operating Debug above is, maybe it can solve the urgent problem~:)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 6 Posted 2006-12-19 02:49 ·  中国 安徽 马鞍山 电信
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
GMY's one-click GHOST does not itself judge the available space size of the partition where the backup is saved. Instead, it provides the reason based on the error file generated by GHOST when GHOST encounters an error.
Windows 一键还原
http://www.yjhy.com
Floor 7 Posted 2007-02-09 22:53 ·  中国 广东 广州 珠江宽频
中级用户
★★
Credits 210
Posts 85
Joined 2007-01-14 12:38
19-year member
UID 76501
Gender Male
From 广东广州
Status Offline
Implementing under DOS is relatively complicated. The following is an example of using batch to extend strings.com:

@echo off
echo.
set v=
dir d:\|find "free">tmp
strings s=read tmp,1
strings/p- s=mid %s%-9
strings/p- s=parse %s%-1
strings/p- s1=parse %s%-1-,
strings/p- s2=parse %s%-2-,
strings/p- s3=parse %s%-3-,
strings v=sub %s1%%s2%%s3%,1024>unl
if "%v%"=="" goto lss
echo DiskFree ">" 1GB
goto end
:lss
echo DiskFree "<" 1GB
:end
del tmp
echo.

[ Last edited by lizaoyou on 2007-2-9 at 09:55 AM ]
Floor 8 Posted 2007-05-01 19:35 ·  中国 广东 广州 南沙区 电信
初级用户
Credits 98
Posts 47
Joined 2007-01-28 05:39
19-year member
UID 77912
Gender Male
Status Offline
Forum Jump: