Computer Hope


Computer Hope Forum Welcome, Guest. Please login or register.
March 21, 2010, 11:42:58 PM
Home Help Staff Chat Login Register
News: Have your own custom built computer? Come join the self-built computer club.

Computer Hope - Computer Help Forums  >>  Microsoft  >>  Microsoft DOS  >>  Topic: Logging a folders content size? 0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: Logging a folders content size?  (Read 447 times)
DaveLembke
Topic Starter
Adviser
*
Posts: 961

Thanked: 19
OS: Windows XP
Computer: Specs
Experience: Experienced




« on: October 30, 2009, 09:51:29 AM »

I am looking for a way to log a folders content size such as C:\squid\var\cache for the Cache folder to log the size of the Cache storage. I was thinking I could use DIR and a switch to output the size, and Icant remember how I did it a long ways back. Would be nice to export the echo from the command for the folder size to a log file such as below, when executed from C:\squid\var\cache\

Fri 10/30/2009 at 11:43:01.28 Cache Folder is 124,656,576 bytes

The Cache folder has a bunch of sub directories that are stumping me on how to extract the size of the folder contents since DIR normally shows the local file content size, then the whole for the system below that, without the properties of the local folder and sub-directories contained within it.


I know that the batch will be something like below where "DIR" will need to have something else done with it to get the output required. So looking for expert help where I am stumped. Maybe DIR isnt the way to handle this Huh?

@echo. %date% at %time% Cache Folder is >>CacheSize.log
DIR>>CacheSize.Log
« Last Edit: October 30, 2009, 11:04:44 AM by DaveLembke » Logged

Favorite Tools:
#1 - Norton Ghost 2003 (My absolute favorite QUICK multifunctional system restore package !!!)
#2 - GetDataBack NTFS ( Crashed Drive Data Recovery )
#3 - CamStudio 2.0 ( Free Open source AVI recorder )
#4 - Virtual PC 2007 ( Running Virtual OS Testing Environments )
Salmon Trout
Expert
*
Posts: 2052

Thanked: 130
OS: Windows XP
Experience: Guru


« Reply #1 on: October 30, 2009, 11:01:42 AM »


DIR normally shows the local file content size, then the whole for the system below that, without the properties of the local folder and sub-directories contained within it.


Executed from a folder, Dir shows the names of any subfolders, and the names, dates and sizes of any files present in the folder, and the total size in bytes of the files in the folder only.

S:\Test\Batch>dir
 Volume in drive S is USBHD
 Volume Serial Number is 2C51-AA7F

 Directory of S:\Test\Batch

26/09/2009  20:46    <DIR>          .
26/09/2009  20:46    <DIR>          ..
28/10/2009  21:02    <DIR>          After 07-09-09
07/09/2009  17:13    <DIR>          Older
15/05/2009  06:52    <DIR>          EditVS
15/05/2009  06:56    <DIR>          sst26
27/05/2009  17:56               116 Finder.bat
26/09/2009  20:46                44 getp2.bat
18/09/2009  16:51               217 isfolder.vbs
15/09/2009  17:48                46 ddf.vbs
09/05/2009  07:56                78 rarhelp.bat
25/05/2009  18:58                37 dequote.vbs
23/06/2009  19:34               245 Edit3
               7 File(s)            783 bytes <-----------------------------------------
               6 Dir(s)  146,969,190,400 bytes free


Are you saying you want to know the amount of data in each subfolder?

« Last Edit: November 01, 2009, 03:42:07 PM by Salmon Trout » Logged

1Z50 is through Banbury Lane and coming hard.
DaveLembke
Topic Starter
Adviser
*
Posts: 961

Thanked: 19
OS: Windows XP
Computer: Specs
Experience: Experienced




« Reply #2 on: October 30, 2009, 11:09:57 AM »

Hello...Yes I want to know how much total combined within local folder Cache and subfolders. I added a screenshot to show the subdirectory structure. I was thinking that maybe a DIR would have to be run against each sub directory and the sum of the files within it passed to a variable for every sub-folder/directory then the variables all added up at the end to give the lump sum of all data contained within Cache as the physical size of that folder and its sub-folders. (( But there has to be an easier method I am thinking ))
Logged

Favorite Tools:
#1 - Norton Ghost 2003 (My absolute favorite QUICK multifunctional system restore package !!!)
#2 - GetDataBack NTFS ( Crashed Drive Data Recovery )
#3 - CamStudio 2.0 ( Free Open source AVI recorder )
#4 - Virtual PC 2007 ( Running Virtual OS Testing Environments )
Salmon Trout
Expert
*
Posts: 2052

Thanked: 130
OS: Windows XP
Experience: Guru


« Reply #3 on: October 30, 2009, 11:45:37 AM »

Are you able (permitted) to use the Sysinternals du utility?

http://live.sysinternals.com/du.exe

if so I will rough out a batch file


Logged

1Z50 is through Banbury Lane and coming hard.
gh0std0g74
Apprentice
*
Posts: 590

Thanked: 37
OS: Linux Variant
Experience: Experienced


« Reply #4 on: October 30, 2009, 06:42:19 PM »

see my sig (GNU tools). Download  and use them. It includes du command, plus others such as find (that is way better than Windows own), stat, etc you can use to show you sizes of files and folders.  Of course, only if you are allowed to.
Logged

DaveLembke
Topic Starter
Adviser
*
Posts: 961

Thanked: 19
OS: Windows XP
Computer: Specs
Experience: Experienced




« Reply #5 on: October 31, 2009, 01:30:56 AM »

Hello Salmon...sure I am sys admin and can run that. So if you can show a way to use DU and do that, that would be awesome.
Logged

Favorite Tools:
#1 - Norton Ghost 2003 (My absolute favorite QUICK multifunctional system restore package !!!)
#2 - GetDataBack NTFS ( Crashed Drive Data Recovery )
#3 - CamStudio 2.0 ( Free Open source AVI recorder )
#4 - Virtual PC 2007 ( Running Virtual OS Testing Environments )
gh0std0g74
Apprentice
*
Posts: 590

Thanked: 37
OS: Linux Variant
Experience: Experienced


« Reply #6 on: October 31, 2009, 02:14:39 AM »

just type du c:\ for example on the command prompt. if you want, use a for loop to grab results. simple as that.
Logged

Salmon Trout
Expert
*
Posts: 2052

Thanked: 130
OS: Windows XP
Experience: Guru


« Reply #7 on: October 31, 2009, 02:43:24 AM »

just type du c:\ for example on the command prompt. if you want, use a for loop to grab results. simple as that.

Yes indeedy. Play around to get the syntax clear. Du /? to see help, where the various switches available are explained.

(I am using the Sysinternals du.exe)

Code below shows:

You can use the -q switch to prevent the Sysinternals copyright message (which, incidentally, if enabled echos to stderr not stdout)

I use quotes around folder names as good practice in case of spaces

Can pipe through Find "Size:" to get the line with file size

Comma separated file(s) size in bytes is 2nd token in that line

Remove commas from size to make suitable for set /a

Code:
set dirname=C:\squid\var\cache
for /f "tokens=1-2" %%A in ('du -q "%dirname%" ^| find "Size:"') do set foldersize=%%B
set foldersize=%foldersize:,=%
Logged

1Z50 is through Banbury Lane and coming hard.
gh0std0g74
Apprentice
*
Posts: 590

Thanked: 37
OS: Linux Variant
Experience: Experienced


« Reply #8 on: October 31, 2009, 03:02:31 AM »

i would recommend the GNU version since it has more capabilities and more or less works on a *nix with GNU as well.
Logged

Salmon Trout
Expert
*
Posts: 2052

Thanked: 130
OS: Windows XP
Experience: Guru


« Reply #9 on: October 31, 2009, 03:41:14 AM »

The Sysinternals version is simpler to manipulate (I have both) but as you say the GNU version is less limited (no commas in output. Another thing to consider might be DIRUSE from the NT Resource Kit

http://support.microsoft.com/kb/927229


Code:
D:\Audio-DL>diruse /s "Amaral Discografia"

    Size  (b)  Files  Directory
     23503006      1  AMARAL DISCOGRAFIA
     45934192     13  AMARAL DISCOGRAFIA\Amaral
    216104622     46  AMARAL DISCOGRAFIA\split-IOtest
     73095739     13  AMARAL DISCOGRAFIA\Una Peque帶 Parte del Mundo
    358637559     73  SUB-TOTAL: AMARAL DISCOGRAFIA

    358637559     73  TOTAL: AMARAL DISCOGRAFIA

D:\Audio-DL>diruse /s "Amaral Discografia" | find "TOTAL:"
    358637559     73  SUB-TOTAL: AMARAL DISCOGRAFIA
    358637559     73  TOTAL: AMARAL DISCOGRAFIA

D:\Audio-DL>diruse /s "Amaral Discografia" | find "TOTAL:" | find /V "SUB-TOTAL:"
    358637559     73  TOTAL: AMARAL DISCOGRAFIA

Code:
D:\Audio-DL>du -v "Amaral Discografia"

Du v1.31 - report directory disk usage
Copyright (C) 2005-2006 Mark Russinovich
Sysinternals - www.sysinternals.com

    44,857  D:\Audio-DL\amaral discografia\Amaral
   211,039  D:\Audio-DL\amaral discografia\split-IOtest
    71,382  D:\Audio-DL\amaral discografia\Una Peque帶 Parte del Mundo
   350,231  D:\Audio-DL\amaral discografia

Totals:
Files:        73
Directories:  3
Size:         358,637,559 bytes
Size on disk: 358,637,559 bytes

Code:
D:\Audio-DL>gnuDU -b -c "Amaral Discografia"
45934192        Amaral Discografia/Amaral
216104622       Amaral Discografia/split-IOtest
73095739        Amaral Discografia/Una Peque帶 Parte del Mundo
358637559       Amaral Discografia
358637559       total

D:\Audio-DL>gnuDU -b -c "Amaral Discografia" | find "total"
358637559       total


« Last Edit: October 31, 2009, 04:03:24 AM by Salmon Trout » Logged

1Z50 is through Banbury Lane and coming hard.
DaveLembke
Topic Starter
Adviser
*
Posts: 961

Thanked: 19
OS: Windows XP
Computer: Specs
Experience: Experienced




« Reply #10 on: October 31, 2009, 09:06:41 AM »

Cool... Thanks for your help guys. Going to play with it and learn it.
Logged

Favorite Tools:
#1 - Norton Ghost 2003 (My absolute favorite QUICK multifunctional system restore package !!!)
#2 - GetDataBack NTFS ( Crashed Drive Data Recovery )
#3 - CamStudio 2.0 ( Free Open source AVI recorder )
#4 - Virtual PC 2007 ( Running Virtual OS Testing Environments )
Salmon Trout
Expert
*
Posts: 2052

Thanked: 130
OS: Windows XP
Experience: Guru


« Reply #11 on: October 31, 2009, 02:24:35 PM »

The Sysinternals version is simpler to manipulate (I have both) but as you say the GNU version is less limited. Another thing to consider might be DIRUSE from the NT Resource Kit

http://support.microsoft.com/kb/927229


Code:
D:\Audio-DL>diruse /s "Amaral Discografia"

    Size  (b)  Files  Directory
     23503006      1  AMARAL DISCOGRAFIA
     45934192     13  AMARAL DISCOGRAFIA\Amaral
    216104622     46  AMARAL DISCOGRAFIA\split-IOtest
     73095739     13  AMARAL DISCOGRAFIA\Una Peque帶 Parte del Mundo
    358637559     73  SUB-TOTAL: AMARAL DISCOGRAFIA

    358637559     73  TOTAL: AMARAL DISCOGRAFIA

D:\Audio-DL>diruse /s "Amaral Discografia" | find "TOTAL:"
    358637559     73  SUB-TOTAL: AMARAL DISCOGRAFIA
    358637559     73  TOTAL: AMARAL DISCOGRAFIA

D:\Audio-DL>diruse /s "Amaral Discografia" | find "TOTAL:" | find /V "SUB-TOTAL:"
    358637559     73  TOTAL: AMARAL DISCOGRAFIA

Code:
D:\Audio-DL>du -v "Amaral Discografia"

Du v1.31 - report directory disk usage
Copyright (C) 2005-2006 Mark Russinovich
Sysinternals - www.sysinternals.com

    44,857  D:\Audio-DL\amaral discografia\Amaral
   211,039  D:\Audio-DL\amaral discografia\split-IOtest
    71,382  D:\Audio-DL\amaral discografia\Una Peque帶 Parte del Mundo
   350,231  D:\Audio-DL\amaral discografia

Totals:
Files:        73
Directories:  3
Size:         358,637,559 bytes
Size on disk: 358,637,559 bytes

Code:
D:\Audio-DL>gnuDU -b -c "Amaral Discografia"
45934192        Amaral Discografia/Amaral
216104622       Amaral Discografia/split-IOtest
73095739        Amaral Discografia/Una Peque帶 Parte del Mundo
358637559       Amaral Discografia
358637559       total

D:\Audio-DL>gnuDU -b -c "Amaral Discografia" | find "total"
358637559       total



Logged

1Z50 is through Banbury Lane and coming hard.
Helpmeh
Egghead
*
Posts: 3032

Thanked: 97
OS: Windows XP
Computer: Specs
Experience: Experienced



Roar.


« Reply #12 on: November 01, 2009, 01:41:05 PM »

Executed from a folder, Dir shows the names of any subfolders, and the names, dates and sizes of any filespresent in the folder, and the total size in bytes of the files in the folderonly.

S:\Test\Batch>dir
 Volume in drive S is USBHD
 Volume Serial Number is 2C51-AA7F

 Directory of S:\Test\Batch

26/09/2009  20:46    <DIR>          .
26/09/2009  20:46    <DIR>          ..
28/10/2009  21:02    <DIR>          After 07-09-09
07/09/2009  17:13    <DIR>          Older
15/05/2009  06:52    <DIR>          EditVS
15/05/2009  06:56    <DIR>          sst26
27/05/2009  17:56               116 Finder.bat
26/09/2009  20:46                44 getp2.bat
18/09/2009  16:51               217 isfolder.vbs
15/09/2009  17:48                46 ddf.vbs
09/05/2009  07:56                78 rarhelp.bat
25/05/2009  18:58                37 dequote.vbs
23/06/2009  19:34               245 Edit3
               7 File(s)            783 bytes <-----------------------------------------
               6 Dir(s)  146,969,190,400 bytes free


Are you saying you want to know the amount of data in each subfolder?


I bolded the text that the op wants. It seems that even though salmon put it in red, no one noticed.
Logged
gh0std0g74
Apprentice
*
Posts: 590

Thanked: 37
OS: Linux Variant
Experience: Experienced


« Reply #13 on: November 01, 2009, 05:13:10 PM »

that part only shows the size in the current directory. how about the rest of the directories? you have to individually go into each directory under s:\test\batch and get those sizes and add them up. Extra coding, extra brain cells killed.
Logged

Salmon Trout
Expert
*
Posts: 2052

Thanked: 130
OS: Windows XP
Experience: Guru


« Reply #14 on: November 02, 2009, 12:38:37 AM »

that part only shows the size in the current directory. how about the rest of the directories? you have to individually go into each directory under s:\test\batch and get those sizes and add them up. Extra coding, extra brain cells killed.

Yes, I wrote a huge batch that went one level deep doing just that before I remembered I had du and diruse. You can even use xcopy in list mode but that is probably just as tedious as using dir.
Logged

1Z50 is through Banbury Lane and coming hard.
Pages: [1] - (Top) Print 
Computer Hope - Computer Help Forums  >>  Microsoft  >>  Microsoft DOS  >>  Topic: Logging a folders content size? « previous next »
Jump to:  


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright 1998-2010 by Computer Hope (tm). All rights reserved
Powered by SMF 1.1.8 | SMF © 2006-2008, Simple Machines LLC
Page created in 0.134 seconds with 20 queries.