Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
total size of files
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  17 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tom1  
View profile  
 More options Nov 18 2009, 3:19 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Tom1 <usernetu...@yahoo.com>
Date: Wed, 18 Nov 2009 07:19:59 -0800 (PST)
Local: Wed, Nov 18 2009 3:19 pm
Subject: total size of files
I need a script to find out the number & total size of files based
upon the file extention across about 30 servers. I'm searching for mdb
files. The script will be run remotely against local drives on these
servers. Thanks

    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Lavedas  
View profile  
 More options Nov 18 2009, 3:43 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Tom Lavedas <tglba...@cox.net>
Date: Wed, 18 Nov 2009 07:43:09 -0800 (PST)
Local: Wed, Nov 18 2009 3:43 pm
Subject: Re: total size of files
On Nov 18, 10:19 am, Tom1 <usernetu...@yahoo.com> wrote:

> I need a script to find out the number & total size of files based
> upon the file extention across about 30 servers. I'm searching for mdb
> files. The script will be run remotely against local drives on these
> servers. Thanks

<warning>
<aircode>

with createobject("scripting.filesystemobject")
  aComputers = split(.opentextfile("D:\Someplace\complist.txt", _
                1).readall, vbnewline)
end with

nComputers = UBound(aComputers)
Redim aData(nComputers)

for i = 0 to nComputers
  nSize = 0
  nCount = 0
  Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
        aComputers(i) & "\root\cimv2")
  Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_DataFile where Extension = 'mdb'", , 48)
  For Each objFile in colFiles
    nSize = nSize + objFile.size
  Next
  nCount = nCount + colFiles.count
  aData(i) = Join(Array(aComputers(i), nCount, nSize), ", ")
Next

wsh.echo Join(aData, vbnewline)

</aircode>
</warning>

Another warning:  CIM_DataFile searches are SLOW.  Be prepared to W -
A - I - T.
_____________________
Tom Lavedas


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom1  
View profile  
 More options Nov 18 2009, 4:40 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Tom1 <usernetu...@yahoo.com>
Date: Wed, 18 Nov 2009 08:40:16 -0800 (PST)
Local: Wed, Nov 18 2009 4:40 pm
Subject: Re: total size of files
On Nov 18, 10:43 am, Tom Lavedas <tglba...@cox.net> wrote:

Thanks but I get the following error message:

test.vbs(22, 5) Microsoft VBScript runtime error: Object doesn't
support this property or method: 'size'


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Lavedas  
View profile  
 More options Nov 18 2009, 4:58 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Tom Lavedas <tglba...@cox.net>
Date: Wed, 18 Nov 2009 08:58:39 -0800 (PST)
Local: Wed, Nov 18 2009 4:58 pm
Subject: Re: total size of files
On Nov 18, 11:40 am, Tom1 <usernetu...@yahoo.com> wrote:

I was afraid of that - I keep forgetting what the differences are
between Shell.Application and FSO.  OK, try this mod ...

set fso =  createobject("scripting.filesystemobject")
with fso
  aComputers = split(.opentextfile("D:\Someplace\complist.txt", _
                1).readall, vbnewline)
end with

nComputers = UBound(aComputers)
Redim aData(nComputers)

for i = 0 to nComputers
  nSize = 0
  nCount = 0
  Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
        aComputers(i) & "\root\cimv2")
  Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_DataFile where Extension = 'mdb'", , 48)
  For Each objFile in colFiles
    nSize = nSize + fso.GetFile(objFile.Path).size
  Next
  nCount = nCount + colFiles.count
  aData(i) = Join(Array(aComputers(i), nCount, nSize), ", ")
Next

wsh.echo Join(aData, vbnewline)
_____________________
Tom Lavedas


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pegasus [MVP]  
View profile  
 More options Nov 18 2009, 4:59 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Wed, 18 Nov 2009 17:59:48 +0100
Local: Wed, Nov 18 2009 4:59 pm
Subject: Re: total size of files

"Tom1" <usernetu...@yahoo.com> wrote in message

news:b56abc7b-efa0-449f-9d42-dfcd054e3ccd@k4g2000yqb.googlegroups.com...

>I need a script to find out the number & total size of files based
> upon the file extention across about 30 servers. I'm searching for mdb
> files. The script will be run remotely against local drives on these
> servers. Thanks

In view of Tom's explicit warning about the slowness of the WMI solution,
what's wrong with the humble "dir" command? It can access remote resources
and it is *much* faster than WMI.

    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Lavedas  
View profile  
 More options Nov 18 2009, 5:13 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Tom Lavedas <tglba...@cox.net>
Date: Wed, 18 Nov 2009 09:13:30 -0800 (PST)
Local: Wed, Nov 18 2009 5:13 pm
Subject: Re: total size of files
On Nov 18, 11:58 am, Tom Lavedas <tglba...@cox.net> wrote:

Oops, wrong property.  Change objFile.Path to objFile.Name.

I told you I keep getting the differences confused.

And, unless the administrative shares have been removed (C$, D$,
etc.), Pegusus' approach is at least as good, if not better ...

  dir \\computername\C$\*.mdb /s | find " File(s) "

I keep forgetting about the administrative share!  (and this is a VBS
group ;-)
_____________________
Tom Lavedas


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom1  
View profile  
 More options Nov 18 2009, 5:14 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Tom1 <usernetu...@yahoo.com>
Date: Wed, 18 Nov 2009 09:14:17 -0800 (PST)
Local: Wed, Nov 18 2009 5:14 pm
Subject: Re: total size of files
On Nov 18, 11:58 am, Tom Lavedas <tglba...@cox.net> wrote:

Still not working -- test.vbs(24, 5) Microsoft VBScript runtime error:
File not found

    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom1  
View profile  
 More options Nov 18 2009, 5:47 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Tom1 <usernetu...@yahoo.com>
Date: Wed, 18 Nov 2009 09:47:05 -0800 (PST)
Local: Wed, Nov 18 2009 5:47 pm
Subject: Re: total size of files
On Nov 18, 12:13 pm, Tom Lavedas <tglba...@cox.net> wrote:

Thanks Tom

Is there a way to get just the total count & size? I just ran the
following command:

dir \\server1\h$:\*.ppt /s | find " File(s) "

          19 File(s)     49,850,383 bytes
           2 File(s)     14,699,520 bytes
          13 File(s)     20,429,824 bytes
           3 File(s)      8,284,672 bytes
           6 File(s)      9,275,392 bytes
           1 File(s)      2,814,464 bytes
           6 File(s)     28,538,880 bytes
           2 File(s)      9,221,632 bytes
           9 File(s)     16,318,976 bytes
           7 File(s)     11,241,472 bytes
          10 File(s)     46,939,648 bytes
           2 File(s)      6,682,112 bytes
           2 File(s)     12,724,224 bytes
          14 File(s)     30,193,152 bytes
           1 File(s)      5,980,160 bytes
           1 File(s)      1,647,104 bytes
           5 File(s)     29,892,096 bytes
           1 File(s)      2,814,464 bytes
           4 File(s)     13,792,256 bytes
           1 File(s)      3,254,784 bytes
         109 File(s)    324,595,215 bytes

As you can see, all I need is the 109 files & the 324,595,215 bytes in
the output (not interested in the numbers before that). Is this
doable?


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pegasus [MVP]  
View profile  
 More options Nov 18 2009, 6:15 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Wed, 18 Nov 2009 19:15:23 +0100
Local: Wed, Nov 18 2009 6:15 pm
Subject: Re: total size of files

"Tom1" <usernetu...@yahoo.com> wrote in message

news:5d0dafb7-867f-4d84-b6c7-bf3b87ef96ea@b2g2000yqi.googlegroups.com...
On Nov 18, 12:13 pm, Tom Lavedas <tglba...@cox.net> wrote:

Thanks Tom

Is there a way to get just the total count & size? I just ran the
following command:

dir \\server1\h$:\*.ppt /s | find " File(s) "

          19 File(s)     49,850,383 bytes
           2 File(s)     14,699,520 bytes
          13 File(s)     20,429,824 bytes
           3 File(s)      8,284,672 bytes
           6 File(s)      9,275,392 bytes
           1 File(s)      2,814,464 bytes
           6 File(s)     28,538,880 bytes
           2 File(s)      9,221,632 bytes
           9 File(s)     16,318,976 bytes
           7 File(s)     11,241,472 bytes
          10 File(s)     46,939,648 bytes
           2 File(s)      6,682,112 bytes
           2 File(s)     12,724,224 bytes
          14 File(s)     30,193,152 bytes
           1 File(s)      5,980,160 bytes
           1 File(s)      1,647,104 bytes
           5 File(s)     29,892,096 bytes
           1 File(s)      2,814,464 bytes
           4 File(s)     13,792,256 bytes
           1 File(s)      3,254,784 bytes
         109 File(s)    324,595,215 bytes

As you can see, all I need is the 109 files & the 324,595,215 bytes in
the output (not interested in the numbers before that). Is this
doable?

======

Sure is - with a little batch file (which is often frowned upon in this
newsgroup):

[1] @echo off
[2] for /F "tokens=3" %%a in ('dir \\server1\h$:\*.ppt /s ^| find " File(s)
"') do set Total=%%a
[3] echo Total=%Total%

You need to unwrap wrapped lines (if necessary) and remove the line numbers.
If desired then you can expand the above batch script so that it scans a
whole set of servers and adds up the numbers to a grand total.


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Lavedas  
View profile  
 More options Nov 18 2009, 7:41 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Tom Lavedas <tglba...@cox.net>
Date: Wed, 18 Nov 2009 11:41:52 -0800 (PST)
Local: Wed, Nov 18 2009 7:41 pm
Subject: Re: total size of files
On Nov 18, 1:15 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:

> "Tom1" <usernetu...@yahoo.com> wrote in message

>{snip}

> Sure is - with a little batch file (which is often frowned upon in this
> newsgroup):

> [1] @echo off
> [2] for /F "tokens=3" %%a in ('dir \\server1\h$:\*.ppt /s ^| find " File(s)
> "') do set Total=%%a
> [3] echo Total=%Total%

> You need to unwrap wrapped lines (if necessary) and remove the line numbers.
> If desired then you can expand the above batch script so that it scans a
> whole set of servers and adds up the numbers to a grand total.

My personal choice would be something like this...

 @echo off
  setlocal
  for /F "tokens=1,3" %%a in (
    'dir dir \\server1\h$\*.mdb /s /-c^| find " File(s)"'
    ) do set /a FileCount=%%a,Total=%%b
  echo %FileCount% files totaling %Total% bytes

Pegusus: Note the /-C switch to remove the commas from the listing.
Also, the colon after the share name does not belong.
_____________________
Tom Lavedas


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pegasus [MVP]  
View profile  
 More options Nov 18 2009, 8:18 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Wed, 18 Nov 2009 21:18:03 +0100
Local: Wed, Nov 18 2009 8:18 pm
Subject: Re: total size of files

"Tom Lavedas" <tglba...@cox.net> wrote in message

news:6202aad0-14dc-47bd-86b0-f1a2a7ffc55c@d10g2000yqh.googlegroups.com...
On Nov 18, 1:15 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:

My personal choice would be something like this...

 @echo off
  setlocal
  for /F "tokens=1,3" %%a in (
    'dir dir \\server1\h$\*.mdb /s /-c^| find " File(s)"'
    ) do set /a FileCount=%%a,Total=%%b
  echo %FileCount% files totaling %Total% bytes

Pegusus: Note the /-C switch to remove the commas from the listing.
Also, the colon after the share name does not belong.
_____________________
Tom Lavedas

==========

Thanks for picking up the extra colon. It was actually the OP's doing but I
admit that I overlooked it. In your code there is an oversight too - the two
"dir dir" commands should proably be reduced to just one.

I'm aware of the /-c switch for the "dir" command - it would come in handy
if the OP decided to total up the numbers from several servers. Conversely -
why would you use the /a switch for the "set" command? You're not
calculating any arithmetic expression.

I note with concern that we're deep into a batch file discussion even though
we're in a VB Scripting group. I can feel the flames scorching my backside.


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Lavedas  
View profile  
 More options Nov 18 2009, 9:04 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Tom Lavedas <tglba...@cox.net>
Date: Wed, 18 Nov 2009 13:04:16 -0800 (PST)
Local: Wed, Nov 18 2009 9:04 pm
Subject: Re: total size of files
On Nov 18, 3:18 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:

The group has tuned this thread out already, I would guess.

The double 'dir' is a c&p problem - thanks for catching that.

I removed the commas to get the complete number.  Otherwise, it would
have just collected the most significant grouping in the US.  You're
in an locale that uses dots, I believe, so what you posted will work
as expected.  Here in the US, the standard comma separator causes
problems because it is also a command line delimiter.

Finally, I used the /A so I could collect both the file count and size
numbers in one SET statement using the comma 'expression
separator' (last operand in the SET help listing).  (That's another
reasons for the /A switch in the SET.)
_____________________
Tom Lavedas


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Lavedas  
View profile  
 More options Nov 18 2009, 10:16 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Tom Lavedas <tglba...@cox.net>
Date: Wed, 18 Nov 2009 14:16:41 -0800 (PST)
Local: Wed, Nov 18 2009 10:16 pm
Subject: Re: total size of files
On Nov 18, 12:14 pm, Tom1 <usernetu...@yahoo.com> wrote:

> Still not working -- test.vbs(24, 5) Microsoft VBScript runtime error:
> File not found

OK.  I give up on that approach.  It's too slow anyway.  However, you
can do it in VBS with a recursive search using FSO via the
administrative share, as we did with the command line DIR.

Something like this ...

set ofs = createobject("scripting.filesystemobject")
aComputers = split(fso.opentextfile("D:\Someplace\complist.txt", _
                1).readall, vbnewline)

nComputers = UBound(aComputers)
Redim aData(nComputers)

for i = 0 to nComputers
  nSize = 0
  nCount = 0
  dpath = "\\" & aComputers(i) & "\C$\"
  getSize dPath, "mdb", nCount, nSize, fso
  aData(i) = Join(Array(aComputers(i), nCount, nSize), ", ")
Next

wsh.echo Join(aData, vbnewline)

Sub getSize(sPath, sExt, nCount, nSize, ofs)
Dim s
  s = ""
  With ofs.GetFolder(sPath)
    getFileSize .files, sExt, nCount, nSize, fso
    if .SubFolders.Count > 0 Then
      For each folder in .SubFolders
        getSize sPath & "\" & folder.Name, sExt, nCount, nSize, ofs
      Next
    End if
  End With
End Sub

Sub getFileSize(cFiles, sExt, nCount, nSize, fso)
  For each file in cFiles
    if lcase(ofs.getExtensionName(file.name)) = lcase(sExt) then
      nCount = nCount + 1
      nSize = nSize + file.size
    end if
  Next
end sub
_____________________
Tom Lavedas


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Randall  
View profile  
 More options Nov 19 2009, 12:57 am
Newsgroups: microsoft.public.scripting.vbscript
From: "Paul Randall" <paulr...@cableone.net>
Date: Wed, 18 Nov 2009 17:57:02 -0700
Local: Thurs, Nov 19 2009 12:57 am
Subject: Re: total size of files

"Pegasus [MVP]" <n...@microsoft.com> wrote in message

news:ef0K9wIaKHA.5348@TK2MSFTNGP06.phx.gbl...

> snip

> I note with concern that we're deep into a batch file discussion even
> though we're in a VB Scripting group. I can feel the flames scorching my
> backside.

Seems to me that this batch file will be called from a VBScript and perhaps
its output will be redirected to the same VBScript, all within a Microsoft
OS.  To me that is a good enough reason to have this discussion nere, on how
to get accurate results to the OP's need without having to wait for the slow
WMI processing that few would quibble with discussing here.

-Paul Randall


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom1  
View profile  
 More options Nov 19 2009, 9:27 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Tom1 <usernetu...@yahoo.com>
Date: Thu, 19 Nov 2009 13:27:04 -0800 (PST)
Local: Thurs, Nov 19 2009 9:27 pm
Subject: Re: total size of files
On Nov 18, 3:18 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:

I ran the above script against a 2TB drive. Here is the script output
(after 2 hours & 55 minutes of parsing the data):

Invalid number.  Numbers are limited to 32-bits of precision.
Invalid number.  Numbers are limited to 32-bits of precision.
Invalid number.  Numbers are limited to 32-bits of precision.
1667 files totaling 15508480 bytes

The above results (1667 files totaling 15508480 bytes) are not
correct. The correct numbers are:

Total bytes: 591,657,988,611 (577,791,004.50 KB) (564,249.03 MB)
Total files: 1670   Average size: 354,286,220 bytes
Smallest: 0 bytes   Largest: 6,998,934,528 bytes


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pegasus [MVP]  
View profile  
 More options Nov 19 2009, 9:41 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Thu, 19 Nov 2009 22:41:19 +0100
Local: Thurs, Nov 19 2009 9:41 pm
Subject: Re: total size of files

"Tom1" <usernetu...@yahoo.com> wrote in message

news:d1a9ea69-55fb-47d5-84d9-2f679f6de8cc@f16g2000yqm.googlegroups.com...
On Nov 18, 3:18 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:

I ran the above script against a 2TB drive. Here is the script output
(after 2 hours & 55 minutes of parsing the data):

Invalid number.  Numbers are limited to 32-bits of precision.
Invalid number.  Numbers are limited to 32-bits of precision.
Invalid number.  Numbers are limited to 32-bits of precision.
1667 files totaling 15508480 bytes

The above results (1667 files totaling 15508480 bytes) are not
correct. The correct numbers are:

Total bytes: 591,657,988,611 (577,791,004.50 KB) (564,249.03 MB)
Total files: 1670   Average size: 354,286,220 bytes
Smallest: 0 bytes   Largest: 6,998,934,528 bytes

==============

I'm not surprised. When running such programs, whether as batch files or as
VB Script files, one needs to size up the numbers expected, then adjust the
code so that one stays within acceptable bounds. When it comes to disk space
then I would restrict myself to MBytes. No point in going down to Bytes.

I would also run a test on a medium-size disk to determine which is faster,
a VB Script based on the File System Object or a batch file. And if you want
quick results then a batch file invoked remotely, using psexec.exe, will
beat the lot while creating negligible network traffic.


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Al Dunbar  
View profile  
 More options Nov 20 2009, 3:09 am
Newsgroups: microsoft.public.scripting.vbscript
From: "Al Dunbar" <aland...@hotmail.com>
Date: Thu, 19 Nov 2009 20:09:37 -0700
Local: Fri, Nov 20 2009 3:09 am
Subject: Re: total size of files

"Pegasus [MVP]" <n...@microsoft.com> wrote in message

news:ef0K9wIaKHA.5348@TK2MSFTNGP06.phx.gbl...

Then I need not say anything about it... ;-)

Of course, this type of thing would be even easier in Powershell (another
non-vbscript language), in which files and folders are objects with
properties like "size", and in which numbers with more than 9 digits
overflow.

/Al


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google