Solved

dos directory size

Posted on 2009-07-13
10
2,411 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
ID: 24845544
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
ID: 24846612
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
ID: 24846615
or one less find:
dir c:\ /s | find "bytes" | sort /r | find /v /n "free" | find "[1]"
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 16

Expert Comment

by:t0t0
ID: 24848108
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
ID: 24848121
But there is no For command in msdos.

Steve
0
 
LVL 3

Expert Comment

by:cclassen
ID: 24849502
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
ID: 24849537
dragon-it

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

Accepted Solution

by:
Steve Knight earned 500 total points
ID: 24850553
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 69

Expert Comment

by:Qlemo
ID: 24857941
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
ID: 24901928
Glad if it helped!

Steve
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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