Re: total size of files
- From: Tom Lavedas <tglbatch@xxxxxxx>
- Date: Wed, 18 Nov 2009 13:04:16 -0800 (PST)
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
.
- References:
- total size of files
- From: Tom1
- Re: total size of files
- From: Tom Lavedas
- Re: total size of files
- From: Tom1
- Re: total size of files
- From: Tom Lavedas
- Re: total size of files
- From: Tom Lavedas
- Re: total size of files
- From: Tom1
- Re: total size of files
- From: Pegasus [MVP]
- Re: total size of files
- From: Tom Lavedas
- Re: total size of files
- From: Pegasus [MVP]
- total size of files
- Prev by Date: Re: total size of files
- Next by Date: Re: total size of files
- Previous by thread: Re: total size of files
- Next by thread: Re: total size of files
- Index(es):
Relevant Pages
|