Solved

dos directory size

Posted on 2009-07-13
10
2,430 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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