Solved

dos directory size

Posted on 2009-07-13
10
2,404 Views
Last Modified: 2012-05-07
what is the command to know the size of a directory in dos
0
Comment
Question by:zenworksb
10 Comments
 
LVL 3

Expert Comment

by:ranit8
Comment Utility
I dont know of a command to get only the size. This one lists all files inside directory and displays the total file size at the end.
dir /s /a "c:\my folder name"
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
You can get closer with the find command if present in the dos directory (don't forget is only 8.3 filenames and no quotes needed):
dir /s c:\folder | find "bytes"

and then do some fidding to get it with the limited commands available:

dir /s c:\folder | find "bytes" | find /v "free" | sort /r | find /n "(" | find "[1]"

i.e....

1. take the dir listing with the totals for each subdir which have the word "bytes" only on them.
2. remove all but the "free" line which is the bytes free
3. sort the file into reverse order to get the last entry as first
4. Add line numbers to the file for all lines with
5. Pull out theline number "[1]".

or something like that!

Oh for proper command line tools!

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
or one less find:
dir c:\ /s | find "bytes" | sort /r | find /v /n "free" | find "[1]"
0
 
LVL 16

Expert Comment

by:t0t0
Comment Utility
To get JUST the size as a single integer  value  you need one of the following commands:

COMMAND VERSION
 

for /f "tokens=1-5 delims= " %a in ('dir /-c /s ^| find "e(" ^| sort /r ^| find /n ")" ^| find "[1]"') do @echo %d
 
 

BATCH FILE VERSION
 

for /f "tokens=1-5 delims= " %%a in ('dir /-c /s ^| find "e(" ^| sort /r ^| find /n ")" ^| find "[1]"') do @echo %%d

Open in new window

0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
But there is no For command in msdos.

Steve
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 3

Expert Comment

by:cclassen
Comment Utility
Download and use Diruse
http://www.microsoft.com/downloads/details.aspx?FamilyID=955D7F2F-73D9-4018-9DD7-42DA210E62EE&displaylang=en

DIRUSE displays a list of disk usage for a directory tree(s). Version 1.20

DIRUSE [/S | /V] [/M | /K | /B] [/C] [/,] [/Q:# [/L] [/A] [/D] [/O]] [/*] DIRS

/S      Specifies whether subdirectories are included in the output.
/V      Output progress reports while scanning subdirectories.  Ignored if /S is
 specified.
/M      Displays disk usage in megabytes.
/K      Displays disk usage in kilobytes.
/B      Displays disk usage in bytes (default).
/C      Use Compressed size instead of apparent size.
/,      Use thousand separator when displaying sizes.
/L      Output overflows to logfile .\DIRUSE.LOG.
/*      Uses the top-level directories residing in the specified DIRS
/Q:#    Mark directories that exceed the specified size (#) with a "!".
        (If /M or /K is not specified, then bytes is assumed.)
/A      Specifies that an alert is generated if specified sizes are exceeded.
        (The Alerter service must be running.)
/D      Displays only directories that exceed specified sizes.
/O      Specifies that subdirectories are not checked for specified size
        overflow.
DIRS    Specifies a list of the paths to check.

Note:   Parameters can be typed in any order. And the '-' symbol can be
        used in place of the '/' symbol.

        Also, if /Q is specified, then return code is ONE if any directories are
 found that
        exceed the specified sizes.  Otherwise the return code is ZERO.

Example: diruse /s /m /q:1.5 /l /* c:\users
0
 
LVL 16

Expert Comment

by:t0t0
Comment Utility
dragon-it

What version of DOS are you referring to?
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 500 total points
Comment Utility
DOCS S 6.2 that he says he is using (in related q's).  No version of dos has a for command to my knowledge, afaik it was NT4 up.

Steve
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
Confirmed, the FOR was introduced with NT. I'm not certain about the version, but think it was there in NT3.51 already.
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
Glad if it helped!

Steve
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now