Getting the size of a particular directory ???

Getting the size of a particular directory ???

Post by Tom Mill » Mon, 28 Jul 2003 01:25:46



I would like to get the exact size of a directory (say D:\work) including its sub-directories.

dir

shows ALL the unwanted stuff around.
I just want to get the number of bytes nothing more and assign it to a variable "size".

How do I do this ?

Is there an easier extension in WinNT/Win2000/WinXP DOS?

Thx
Tom

 
 
 

Getting the size of a particular directory ???

Post by Mike Wals » Mon, 28 Jul 2003 03:26:39


Try this in a batch file in the Cmd.exe environment with extensions enable (you should be using this by default).

dir /s/a/-c/-p D:\work |find "File(s)" |find "bytes" |sort > %temp%\size.tmp
for /F "tokens=1,2,3" %%G in (%temp%\size.tmp) do set size=%%I


> I would like to get the exact size of a directory (say D:\work) including its sub-directories.

> dir

> shows ALL the unwanted stuff around.
> I just want to get the number of bytes nothing more and assign it to a variable "size".

> How do I do this ?

> Is there an easier extension in WinNT/Win2000/WinXP DOS?

> Thx
> Tom

--
                   Mike Walsh
            West Palm Beach, Florida, U.S.A.

 
 
 

Getting the size of a particular directory ???

Post by Timo Sal » Mon, 28 Jul 2003 03:20:57



> I would like to get the exact size of a directory (say D:\work) including its sub-directories.

dirw /t /s /q d:\work

ftp://garbo.uwasa.fi/pc/ts/tsutil44.zip Utilities 1st collection T.Salmi
Filename        Comment                              Date      Time
--------        --------------------------------     ----      ----
DAY.EXE         Gives a date in a weekday-format  Apr-19-1998  23:39:24
DIRD.EXE        Directories, different files      Apr-21-1998  16:49:48
DIRS.EXE        Directories, same files           Apr-21-1998  17:03:40
DIRW.EXE        As dir/w, recursive, file status  Apr-21-1998  16:40:32
DTETIM.EXE      Displays current date and time    May-16-1998  20:56:50
DTETIMAL.EXE    Check system clock from autoexec  May-16-1998  21:07:04
FILE_ID.DIZ     Brief characterization of TSUTIL  Apr-19-1998  23:23:04
GRAPINFO.EXE    Detects your graphics hardware    Jun-25-1989  19:13:18
PVMKLO.EXE      Current date and time in Finnish  May-16-1998  21:11:38
PVMKLOHL.EXE    Check system clock in Finnish     May-16-1998  21:13:50
RESET.EXE       Resets 80 col 25/43/50 text mode  May-16-1998  21:18:46
STACK.EXE       Tells available free memory       Feb-20-1991  17:01:26
SYSINF.BAT      Put your system info into a file  May-16-1998  21:49:20
SYSINFO.EXE     Information about your gadget     May-16-1998  21:37:20
TIMDIF.EXE      Difference between two times      May-17-1998  05:25:38
TIMELOG.EXE     For logging program usage         Nov-25-1995  11:14:58
TSPROG.INF      List of programs from Timo Salmi  Apr-18-1998  19:19:34
TSUTIL.INF      Document (and a readme)           May-17-1998  05:43:36
TSUTIL.NWS      News announcements about tsutil   May-17-1998  05:45:06
VAASA.INF       Info: Finland, Vaasa, U of Vaasa  Oct-18-1997  13:18:46
----            ------             ------  -----
0020            282715

   All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa

Timo's  FAQ  materials  at   http://www.uwasa.fi/~ts/http/tsfaq.html

 
 
 

Getting the size of a particular directory ???

Post by Phil Roby » Mon, 28 Jul 2003 07:49:57



> I would like to get the exact size of a directory (say D:\work) including its sub-directories.

> dir

> shows ALL the unwanted stuff around.
> I just want to get the number of bytes nothing more and assign it to a variable "size".

> How do I do this ?

> Is there an easier extension in WinNT/Win2000/WinXP DOS?

> Thx
> Tom

Maybe something like the following:
- - - - - - - - - - begin screen capture - - - - - - - - - -
c:\cmd>demo\SizeOfDirAndSubs
size is 12959326

c:\cmd>demo\SizeOfDirAndSubs c:\temp
size is 920563398

C:\cmd>demo\SizeOfDirAndSubs c:\wylbur
size is 8164426

C:\cmd>rlist demo\SizeOfDirAndSubs.cmd
=====begin C:\cmd\demo\SizeOfDirAndSubs.cmd ====================

2. if [%1] neq [] pushd %1
3. set size=0

5. echo size is %size%
6. if [%1] neq [] popd
=====end   C:\cmd\demo\SizeOfDirAndSubs.cmd ====================
- - - - - - - - - - end   screen capture - - - - - - - - - -

--
Phil Robyn
Univ. of California, Berkeley

u n z i p   m y   a d d r e s s   t o   s e n d   e - m a i l

 
 
 

Getting the size of a particular directory ???

Post by Ted Davi » Mon, 28 Jul 2003 10:01:15




Quote:>I would like to get the exact size of a directory (say D:\work) including its sub-directories.

>dir

>shows ALL the unwanted stuff around.
>I just want to get the number of bytes nothing more and assign it to a variable "size".

>How do I do this ?

>Is there an easier extension in WinNT/Win2000/WinXP DOS?

In what programming language do you want this? What format do you want
the number in?  Are you aware that the total of the sizes of the files
is not an accurate indication of the amount of disk space required to
hold them, and does this matter?  What version of 'DOS' do you
*really* want it for?

If this is a batch question, alt.msdos.batch or alt.msdos.batch.nt
would be a more appropriate place to ask.


 
 
 

Getting the size of a particular directory ???

Post by Dr John Stockto » Mon, 28 Jul 2003 20:29:42



sdos.batch,comp.os.msdos.misc,comp.os.msdos.programmer,alt.msdos.program

Jul 2003 18:25:46 :-

Quote:>I would like to get the exact size of a directory (say D:\work) including its
>sub-directories.

Not, I think, possible; but you can get the total size of the files
within those directories.  A directory is itself a sort of file,
occupying space; but DOS..Win98, at least, do not readily reveal how
much.

Starting in that directory,

        HUNT *.* s q | find "Free" | COLS ` 54-64 | STOW size

will set EnvVar SIZE to the total file size, in up to Win98/ME.  In
younger systems, something will have to substitute for STOW; but

        HUNT *.* s q | find "Free" | COLS 'set * 'size= ` 54-64 > $.bat

gives in $.bat such as

        set size=39355140

You do not state your location; but you appear to be quasi-German.
However, you will not need to translate 'Free' above.

Get HUNT, COLS, STOW via sig line 3.

You could do   dir /s | find " file(s) " | find " bytes" just to list
the file-size totals of the directories - provided that no file had a
LFN containing those strings.

--

 Web  <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
 PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>.
 Do not Mail News to me.    Before a reply, quote with ">" or "> " (SoRFC1036)

 
 
 

Getting the size of a particular directory ???

Post by Ethan Wine » Mon, 28 Jul 2003 23:40:28


Tom,

You want to do this in a DOS program, right? The only way I know is to read
through all the directories and their files one by one and add up all their
sizes.

--Ethan

 
 
 

Getting the size of a particular directory ???

Post by Dr John Stockto » Tue, 29 Jul 2003 06:32:25




26 Jul 2003 18:25:46 :-

Quote:>I would like to get the exact size of a directory (say D:\work) including its
>sub-directories.

To add to my previous reply (to which I cannot yet follow-up) :

With   dir /v    the total allocation in a directory, omitting the
directory itself, is also reported and can be captured similarly, at
least for some OS versions.

There may be error if a file is *named* something too much like

        "         0 dir(s)         176,128 bytes allocated.TXT"

--

 Web  <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
 PAS EXE TXT ZIP via  <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
 My DOS  <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.

 
 
 

Getting the size of a particular directory ???

Post by Ethan Wine » Tue, 29 Jul 2003 23:27:29


Tom,

You want to do this in a DOS program, right? The only way I know is to read
through all the directories and their files one by one and add up all their
sizes.

--Ethan

 
 
 

Getting the size of a particular directory ???

Post by Ray » Wed, 30 Jul 2003 03:50:04


Is this any good?

dir d:\work /s | find "bytes"


Quote:> I would like to get the exact size of a directory (say D:\work) including

its sub-directories.
Quote:

> dir

> shows ALL the unwanted stuff around.
> I just want to get the number of bytes nothing more and assign it to a
variable "size".

> How do I do this ?

> Is there an easier extension in WinNT/Win2000/WinXP DOS?

> Thx
> Tom

 
 
 

Getting the size of a particular directory ???

Post by Joe Batc » Thu, 31 Jul 2003 01:57:20



> I would like to get the exact size of a directory (say D:\work) including its sub-directories.

> dir

> shows ALL the unwanted stuff around.
> I just want to get the number of bytes nothing more and assign it to a variable "size".

> How do I do this ?

Here is the answer to the first part of your question.
If you need help with the variable part, post again.

Line wrapping off, please.

Files and bytes in current directory:
 DIR/A-D/-L/-P/W %optional filespec% |FIND "i"|FIND/V "Volume"

Listing of files and bytes for current and subdirectories:
 DIR/A-D/-L/-P/S/W %optional filespec% |FIND "i"|FIND/V "Volume" |MORE

Total files and bytes in tree:
 DIR/A-D/S/-P/W %optional filespec% |FIND " file(s)"|SORT/R |FIND/N "file(s)"|FIND "[1]"

--
 Batfiles: The DOS Batch File Programming Handbook & Tutorial
 http://purl.oclc.org/net/Batfiles/  
 Using MS-Dos7 Commands http://purl.oclc.org/net/Msdos7/

 
 
 

Getting the size of a particular directory ???

Post by Dr John Stockto » Wed, 30 Jul 2003 20:19:54




posted at Sun, 27 Jul 2003 22:32:25 :-



>26 Jul 2003 18:25:46 :-
>>I would like to get the exact size of a directory (say D:\work) including its
>>sub-directories.

>To add to my previous reply (to which I cannot yet follow-up) :

To add more - there should now be a fresh alpha-test copy of HUNT in
<URL:http://www.merlyn.demon.co.uk/hunt.zip>.

With the Ga option, it rounds all file sizes up to whole clusters,
relying for cluster size on Int 21/1C.  Thus the tailpiece then gives
the number of bytes occupied by the actual files.

Gh & Gs allow commands on Hidden & System files; a V reverses its G.

The size of a directory itself, in DOS proper, can be obtained from the
count of entries, at 32 bytes each, not forgetting . & .. - additional
allowance must be made for Long File Names, remembering that in a LFN
system a file name created in lower case, even within 8.3, needs SFN &
LFN - then round up to a cluster.  HUNT does not do this.

IMHO, any directory needing more than one cluster is too big.

--

 Web  <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
 PAS EXE TXT ZIP via  <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
 My DOS  <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.

 
 
 

Getting the size of a particular directory ???

Post by Charles Dy » Thu, 31 Jul 2003 21:51:24


On Tue, 29 Jul 2003 12:19:54 +0100, Dr John Stockton


>With the Ga option, it rounds all file sizes up to whole clusters,
>relying for cluster size on Int 21/1C.  Thus the tailpiece then gives
>the number of bytes occupied by the actual files.

Probably should check that -- I believe 21/1C returns inaccurate
values on FAT32 volumes.

--

 
 
 

Getting the size of a particular directory ???

Post by Dr John Stockto » Fri, 01 Aug 2003 03:58:16




Wed, 30 Jul 2003 06:51:24 :-

>On Tue, 29 Jul 2003 12:19:54 +0100, Dr John Stockton

>>With the Ga option, it rounds all file sizes up to whole clusters,
>>relying for cluster size on Int 21/1C.  Thus the tailpiece then gives
>>the number of bytes occupied by the actual files.

>Probably should check that -- I believe 21/1C returns inaccurate
>values on FAT32 volumes.

It gives plausible results on my FAT32s, in a Win98 DOS box.

RBIL (seek D-211C in *.f) says :

BUG:    DOS 7.10 (Win95B/Win98) reportedly returns incorrect values in AL and
          DX for FAT12/FAT16 drives, even though it manages correct results
          for FAT32 drives (DOS windows are not affected, only real-mode
          DOS)

That HUNT now says what cluster size it is using, if not scanning multiple
drives.

--

 Web  <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
 PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>.
 Do not Mail News to me.    Before a reply, quote with ">" or "> " (SoRFC1036)

 
 
 

Getting the size of a particular directory ???

Post by Richard Bonn » Wed, 06 Aug 2003 00:16:17



> I would like to get the exact size of a directory (say D:\work)
> including its sub-directories.

***   Use "Color Directory"'s `/I' switch. A link is at my site.

Quote:> I just want to get the number of bytes nothing more and assign it to a
> variable "size".

***  Hmm, that would be harder. You might try XSET. It can place just
about anything into an environment variable, but I don't think it has a
direct option for directory size. A link is at my site.

Quote:> Is there an easier extension in WinNT/Win2000/WinXP DOS?
> Tom

***  The programs I gave above are for DOS and may not work in NT.

          Richard Bonner
http://www.chebucto.ns.ca/~ak621/DOS