[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

determine TOTAL disk size in DOS?

Posted on 2004-09-13
10
Medium Priority
?
1,428 Views
Last Modified: 2010-08-05
1. I want to determine the TOTAL disk space for a drive, then
2. if diskspace <2 GB set x=1
   if didspace >= 2 GB, set x=2

so that I can automatically format a drive (Compact Flash) <2GB as FAT16, and >=2GB as FAT32. (I know the auto-format part!)

Jeroen
PS: ONLY dos-solutions please!!!
0
Comment
Question by:Alfaloe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 10

Expert Comment

by:For-Soft
ID: 12047260
If the drive is unformated, then it could be impossible without some special utility.

What OS are you using?
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12047619
It's important to know if you are running XP/NT/2K or if you are running 9x or if you are running true DOS (6.22 for example).
Each OS has subtly (and not so subtly) different commands for some fairly important command line actions.
0
 

Author Comment

by:Alfaloe
ID: 12047636
I'm using WinXPpro and Win2000. The CF-disks are already formatted, but I want to format them after every download of images to my PC (it prevents a lot of file-corruption, something I can't have as a pro-photographer!!)

Do you think it would be possible in an other script language, then output disk size to a txt-file, and read that line into the DOS-script?

Thanks for that quick reply!!
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 9

Expert Comment

by:DrWarezz
ID: 12047950
Hello Alfaloe,
I'm not sure how to get the capacity of a drive, but once you have it; you could use something like this to determine what the 'x' variable as:

set capacity=[declare the capacity here]
if %capacity% LESS 2 set x=1
if %capacity% GEQ 2 set x=2

best of luck, photo guy  ;-)
[r.D]
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12047969
*Woops, "if %capacity% LESS 2 set x=1" should be:

if %capacity% LSS 2 set x=1

However, being an idiot, I don't know how to get a drives capacity  :o\  Some 'expert' I am :P

Hope that helps for later! :o)

gL,
[r.D]
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12048358
Hmmmm... I've been trying to come up with something, but the numeric operators of DOS are only 4 bytes long.  This creates a problem when trying to do the math necessary in comparing the the actual disk space to the limit of which format to format in.

One question - why not just format everything FAT32?  The smallest "disk" you'll use is an 8 MB and I tend to think if your a professional photographer, you're using much larger drives anyway.
0
 

Author Comment

by:Alfaloe
ID: 12048539
Hi Leew,

FAT32 for all drives would be too easy, wouldn't it ;-) The problem is that not all camera's can handle cards FAT32...

BUT: I think I've found a solution :
1. del all files from the card (easy using XXCOPY with /RCY switch)
2. determine free space:
@for %%a in (MyCFcard) do @if exist %%a:\ @for /F "tokens=2,3" %%b in ('dir %%a:\ /-c') do @if "%%b"=="Dir(s)" set disksize=%%c

if %disksize% LSS 2000000000 goto formatFAT
if %disksize% GEQ 2000000000 goto formatFAT32

Thanx for the suggestions!
0
 
LVL 96

Accepted Solution

by:
Lee W, MVP earned 150 total points
ID: 12048664
I was actually going to suggest something similar - but my tests of the

if %disksize% LSS 2000000000 goto formatFAT
if %disksize% GEQ 2000000000 goto formatFAT32

statements failed if they were greater than a certain number.

Here's what I had come up with for you:  (You'd specify the drive letter to check on the command line for the script - example THISSCRIPT G:)

@echo off
dir %1 > %temp%\dir1.tmp 2>&1
find /i "file not found" %temp%\dir1.tmp > %temp%\dir.tmp 2>NULL
For /f "tokens=1* delims=" %%a in (%temp%\dir.tmp) do IF "%%a" == "File Not Found" Set DriveIs=Empty
del %temp%\dir.tmp
If "%driveis%" NEQ "Empty" Goto GetTotalFree
dir %1 > %1\junktext.tmp

:GetTotalFree
For /f "usebackq tokens=3" %%a in (`dir /-c %1 ^| find "bytes free"`) Do Set /A DiskSize=%%a / 1024
IF %disksize% LEQ 2097152 Goto Format16
rem If 1211798 LEQ 214748 Goto Format16
:Format32
Echo Formatting FAT32 for Drive %1, size %disksize% bytes
REM Execute your format command here to format as FAT32
Goto End

:Format16
Echo Formatting FAT16 for Drive %1, size %disksize% bytes
REM Execute your format command here to format as FAT16

:End
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12048675
Actually (that was the version I was testing to see how large a number I could work with.
0
 

Author Comment

by:Alfaloe
ID: 12049586
How funny Leew, when I started testing for the error you mentioned, I got exactly the OPPOSITE problem: my solution (actually s.o. else's here on EE, but I adapted it a bit) gave errors with SMALL disks (16mb, 64mb), not the 512mb, 1gb and 2gb!

Anyways, your solution WORKED beautifully, thanks, points are for you!

Jeroen
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question