File Size of specific files in a directory

This script lists the size of all files with a specific directory with a specific extension.

Usage:

[Log files in mdbdata]
type=integer
command=cscript /b "dir_size.vbs" "e:\exchsrvr\mdbdata\" ".log"
unit=B
result_pattern=([[:digit:]]+)

Code:

set StdOut = WScript.StdOut
dim fso, file, total_size, folder
set fso = CreateObject("scripting.FileSystemObject")
set folder = fso.getFolder(WScript.Arguments(0))
for each file in folder.files
  if Right(file.name, Len(WScript.Arguments(1)) = WScript.Arguments(1)) then
    total_size = total_size + file.size
  end if
next
StdOut.WriteLine total_size
WScript.Quit(0)