The input parameters are:
dirsize
dir the full path of the target directory
totalsize a variable that keeps a running
total of byte count ie. size
Example:
A directory called "CV" contains 10 files of various
types. The directory is located at
"/Users/Documents/CV"
To find the size of this directory and its contents the
dirsize procedure might be used by another Tcl script
as follows.
source /Users/Documents/TCL/listfiles.tcl
# print the directory size to the console
set total 0.0
dirsize "/Users/Documents/CV" total
puts "Total size of the CV directory is [format "%1.3f" [expr $total / 1000000]] Mb"
The output might look like this,
Total size of the CV directory is 5.413 Mb
Note the use of the source command to "point" the
Tcl interpreter at the directory containing
the dirsize.tcl script.
Refer to dirlist for an example of specifying paths for Windows.
|