################################################################ # proc findBlocksUsed {path pattern}-- # Returns the total number of bytes used by files that match # a pattern # Arguments # path The file path to check # pattern A pattern to use to identify files # # Results # No side effects. Process is recursive. # proc findBlocksUsed {blockSize path pattern} { set total 0 foreach item [glob -nocomplain $path/*] { if {[file type $item] eq "directory"} { set total [expr {$total + [findBlocksUsed $blockSize $item $pattern]}] } else { if {[lsearch [file tail $item] $pattern] == 0} { set total [expr {$total + ([file size $item ]/$blockSize) + 1}] } } } return $total } puts "TOTAL Blocks USED: [findBlocksUsed 4096 [lindex $argv end-1] [lindex $argv end]]"