Solved

dos directory size

Posted on 2009-07-13
10
2,422 Views
Last Modified: 2012-05-07
what is the command to know the size of a directory in dos
0
Comment
Question by:zenworksb
[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
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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 70

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

Suggested Solutions

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 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