Re: total size of files

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Nov 18, 3:18 pm, "Pegasus [MVP]" <n...@xxxxxxxxxxxxx> wrote:
"Tom Lavedas" <tglba...@xxxxxxx> wrote in message

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



"Tom1" <usernetu...@xxxxxxxxx> 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

==========

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.

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
.



Relevant Pages

  • Re: Send same scheduled e-mail, every day?
    ... a command line SMTP mailer and a batch script that ... REM Builds and send a mail message using blat ... echo This mail message produced by %0> %BLAT_MESSAGEBODYFILE% ...
    (microsoft.public.exchange.admin)
  • Re: importing text file question
    ... your DIR command to list file sizes without the commas. ... your folder and FileSize() and FileDateTimeto get the information. ... Is it possible to automate this with VBA? ...
    (microsoft.public.access.modulesdaovba)
  • Re: script question.
    ... This script doesn't seem to do anything other than echo the results back ... Subject: script question. ... Thanks Jean-Marc but how do I get the commas in the result? ... The authorized recipient of this information is prohibited ...
    (AIX-L)
  • Re: System call not acting as expected
    ... You seem to be expecting the latter behaviour, ... Why are you using commas there ... all sorts of fun problems, like having to sort out terminal escape ... > The result of this line confirms that it is generating exactly the command ...
    (comp.lang.perl.misc)
  • RE: Email automatically when a form is closed
    ... You didn't mention where the additional recipients ... Commas are placeholders between options. ... if you use a command button to close the ... at the top click below that and start typing the code. ...
    (microsoft.public.access.forms)