Solved

dos directory size

Posted on 2009-07-13
10
2,405 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 68

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
avoiding the dashes in the sqlcmd output... 1 425
Remove column in output file from batch script 11 55
Printing Folders, SubFolders, Files. 16 200
For loop to add numbers 3 61
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…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 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