Computing.Net > Forums > Disk Operating System > disk size

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

disk size

Reply to Message Icon

Name: novice
Date: June 1, 2001 at 00:16:25 Pacific
Comment:

Is there a possibility to check how big a disk is, and use the size to determine wich sub should run in a batch file.
ex. read the size of a disk a determine if it is bigger the 1.4mb and say this probably not a normal diskette are you sure you want to format



Sponsored Link
Ads by Google

Response Number 1
Name: Laurence
Date: June 1, 2001 at 10:24:43 Pacific
Reply:

Batfiles: The DOS batch file programming handbook

Sure, it's possible.
No time to write it, but
check the techniques on my pages.

Ok here is one I wrote to check if a
file is 2KB. Maybe that will help
give you the idea.

:: is2kb.bat
@ECHO off
IF "%1"=="ReCuRs[" GOTO recurs
IF "%1"=="" ECHO existing filename must be supplied
IF "%1"=="" GOTO end
IF not exist %1 ECHO existing filename must be supplied
IF not exist %1 GOTO end
IF exist enter.bat ECHO enter.bat in current
IF exist enter.bat GOTO end
PATH>%temp%.\respath.bat
PATH %temp%;%path%
SET siz=
SET sep=
SET tar=%1
DIR/A-D/W %1. |FIND " 1 ">%temp%.\result1.dat
ECHO.>>%temp%.\result1.dat
DATE %temp%.\result1.bat
ECHO IF "%%7"=="bytes" set siz=%%6> %temp%.\enter.bat
ECHO IF not "%%7"=="bytes" SET siz=%%6%%7>> %temp%.\enter.bat
FOR %%c IN (CALL DEL) do %%c %temp%.\result1.bat
DEL %temp%.\enter.bat
FOR %%c in (CALL DEL) do %%c %temp%.\respath.bat
ECHO %siz% |FIND "." >nul
IF not errorlevel 1 SET sep=.
ECHO ; |CHOICE.COM /C%siz%; >nul
IF not "%sep%"=="." IF errorlevel 6 ECHO %1 is larger then 2 Kb
IF not "%sep%"=="." IF errorlevel 6 GOTO end
IF not "%sep%"=="." IF errorlevel 1 IF not errorlevel 5 ECHO %1 is smaller than 2 Kb
IF not "%sep%"=="." IF errorlevel 1 IF not errorlevel 5 GOTO end
IF "%sep%"=="." IF errorlevel 7 ECHO %1 is larger then 2 Kb
IF "%sep%"=="." IF errorlevel 7 GOTO end
IF "%sep%"=="." IF errorlevel 2 IF not errorlevel 5 ECHO %1 is smaller than 2Kb
IF "%sep%"=="." IF errorlevel 2 IF not errorlevel 5 GOTO end
ECHO ; |CHOICE.COM/C;%siz%; %0;ReCuRs>%temp%.\parse1.bat
%temp%.\PARSE1.BAT

:recurs
SHIFT 2
IF "%1"=="]?" GOTO end
FOR %%n in (3 4 5 6 7) do IF %%n==%1 ECHO %tar% is larger then 2 Kb
FOR %%n in (3 4 5 6 7) do IF %%n==%1 GOTO end
SHIFT 0
IF "%1"=="." SHIFT
IF not "%1"=="0" ECHO %tar% is larger then 2 Kb
IF not "%1"=="0" GOTO end
SHIFT 4
FOR %%n in (0 1 2 3 4) do IF %%n==%1 GOTO last
ECHO %tar% is larger than 2Kb
GOTO end
:last
SHIFT 8
FOR %%n in (0 1 2 3 4 5 6 7) do IF %%n==%1 ECHO %tar% is smaller than 2Kb
FOR %%n in (0 1 2 3 4 5 6 7) do IF %%n==%1 GOTO end
IF %1==8 ECHO %tar% is exactly 2Kb
IF not %1==8 ECHO %tar% is larger than 2Kb

:end
SET siz=
SET tar=
SET sep=



0

Response Number 2
Name: Laurence
Date: June 1, 2001 at 22:27:27 Pacific
Reply:


I had forgotten I had already written a batch program to do this.

Batfiles: The DOS batch file programming handbook

compsize.bat

http://home7.inet.tele.dk/batfiles/monthly/jan2001.htm


0

Response Number 3
Name: Jim
Date: June 3, 2001 at 18:26:05 Pacific
Reply:

That's quite a batch-file!


0

Response Number 4
Name: Secret_Doom
Date: June 4, 2001 at 15:30:49 Pacific
Reply:

Hi. I was taking a look at the batch file, and was wondering...
is the following line (line 17 from batch) posted correctely?

DATE %temp%.\result1.bat

Wouldn't it be something like

DATE [lessthan] %temp%.\result1.dat|FIND "1">%temp%.\result1.bat

Or am I wrong?
Could you Laurence please clear this to me?

Thanks

-- SECRET_DOOM --


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: disk size

Save total hard disk size in a file www.computing.net/answers/dos/save-total-hard-disk-size-in-a-file/16189.html

NO FIXED DISKS PRESENT www.computing.net/answers/dos/no-fixed-disks-present/8665.html

Ram Disk www.computing.net/answers/dos/ram-disk/5255.html