Z D U - release 2

(C)Copyright 1995-2003 André Jonsson  
Written by:
André Jonsson <haywire@fatalunity.com>

Contents:

1. DISCLAIMER
2. INTRODUCTION
3. REQUIREMENTS
4. INSTALLATION
5. FEATURES
6. SYNTAX & USAGE
7. KNOWN BUGS / LIMITATIONS & BUG REPORTING
8. FUTURE IDEAS
9. DEVELOPMENT
10. AUTHOR
11. VARIOUS
12. SPECIAL THANKS
13. HISTORY
 
 
 
 

1. DISCLAIMER

THIS PROGRAM IS DELIVERED "AS IS" AND ANY USE OF THIS PROGRAM
IS AT YOUR OWN RISK! THE AUTHOR (OR THE SUPPORTING AUTHOR(S)) DOES NOT
TAKE ANY RESPONSABILITY FOR ANY LOSS, OR DAMAGE (PHYSICAL, VIRTUAL OR MENTAL), OF
NEITHER DATA, SOFTWARE, NOR HARDWARE, FROM DIRECT OR INDIRECT USAGE OF
THIS PROGRAM.

2. INTRODUCTION

Zdu is a little tool that can come in handy when cleaning up your hard-drive and general disk information.

The idea behind Zdu is to scan a path (one or more) and report the content therein, how many directories, how many files and how much a specific directory allocates on the harddisk.

You may now think: "What about selecting 'properties' on a folder in windows?". To cut it short, that feature simply sucks, and will decieve you by reporting sometimes (most of the time) a completely wrong directory size. This is mainly because of the way the filesystem works. Zdu determines the filesystem type and the minimum allocation block size on (i.e. clustersize), and makes all size calculations based on that.

There are several, somewhat similar, programs available on the net today, though none of them, fills my needs, Also, most of them are like >150k in size, fancy graphical interface and all that gibberish, which I do not need. I'm also pretty certain that none of the other tools are as configurable as Zdu is.

And from v2.4 Zdu has broadend its views slightly by sporting a graphical user interface (GUI)! It might seem a bit bare-boned, but that is a quite intentional.

3. REQUIREMENTS

A computer.

More specific: an IBM "compatible" PC.

Even more specific:

CPU: 386 or better
MEM: ~1Mb (GUI version ~2Mb) - this depends on the directory scanned
OS: Windows 9x/NT(Intel)/2000/XP
Free disk space: ~140k (including zip file and installed)

And, to put it to some good use, a harddisk is recommended.

At this time no NT-Alpha version has been compiled because I don't have access to any Alpha-based NT box, but if anyone need an Alpha version donations are welcome! :-)

Memory requirements could probably be more, but it seldom uses more than just over 700k. Infact, on my E: drive (now consisting of 28000 files in 2000 dirs with a tree depth of 11) it takes 760k memory (+300k virtual).

And if you think zdu is slow, get a new HD, because over 90% of the CPU power (on my machine) is system time (i.e. disk activity), and Zdu is designed to be streamlined, it always do as little as possible.

4. INSTALLATION

Copy the preferred executable file to any directory, preferrably to one that you  have search-path to (it's more convienient that way). Ofcourse you may copy both of the executables if you wish.
zdu.exe Console version
zdugui.exe GUI version
The executables can of course be renamed, e.g. rename the 'zdugui.exe' to 'zdu.exe' is fine. The two executables are standalone, and do not need the other to operate.

5. FEATURES

Note: this text file does not contain any description of the Zdu GUI. But it is quite simple, and hopefully wont need much introduction.

Zdu's main feature is to scan a given directory and return the ammount of space that it allocates on disk. As default the directories in the directory specified will be listed separately, with a total sum at the bottom. Please note that Zdu returns the REAL(
*) size that the specified path really allocates (for supported filesystems), as opposed to most programs that just returns all file sizes added together (which is basically just crap).

An optional filemask can be given to only return allocated size for certain files.

A simple example of Zdu output when running it on my D: drive:

D:\>zdu
D: "DATA" - FS:FAT32 - 3760:353D Cluster:8k
Total: 15 711 338 496 [14G] - Free: 7 148 961 792 [6G]
 Usage(B)   Dirs   Files  Eff  Path
--------- ------ ------- ----  --------
     1.9G    378    5646  98%  download
      13M     32     205  92%  RECYCLED
     367M    260    5680  93%  data
     7.6M      3      57  97%  usr
     3.6G    349    6421  99%  turbo
     105M     12     138  99%  stefan
     450M      4     172  99%  render
     1.0G    233    2400  98%  haywire
      85M    105    1334  92%  program files
     262M    292    3206  94%  3D
--------- ------ ------- ----  --------
     8.0G   1678   25265  98%  D:\   (depth: 10)
D:\>_

The main GUI looks like this:
Above: Main view   Below: Configurations window

As of version 2.4.14, Zdu sports regular expressions for including and exluding files and directories. The regular expression engine used is PCRE, which is written by Philip Hazel, and copyright by the University of Cambridge England. Its distribution can be downloaded from here ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/.

6. SYNTAX AND USAGE

C:\> zdu /?
This will show a little help page of the command-line usage of zdu. The complex options have more detailed help texts also, accessed with e.g.:
/?:Q
Here follows a complete description of all the switches and options supported by Zdu. Some of them are available (or applicable) only in the console vesion, and are marked as such.

,
Use comma instead of space as thousands separator
Displays 1,234,567 instead of 1 234 567.
b
"Bogus mode" Report file sizes added together instead of cluster allocation.
This only works in the 'Usage by Directory' list.
Note that the 
qualifiers disregard the status of this switch, and always use the actual cluster allocation.
c
Report diskusage in clusters instead of bytes.
Reported sizes in all 'Usage By' lists will show the number of allocated clusters instead of allocated bytes.
d
Display only directories, extentions or users that qualify - Console version only
All qualifiers specified with /Q must be met by the directory/user for it to be listed. See
/Q switch .
e
Ignore scanning errors
Doesn't display (or stop at) any errors encountered during a scan.
f[:size]
Fake clustersize.
Normally Zdu determines the clustersize of the scanned disk automatically. This can be overridden with this flag. This could be useful if comparing a directory on two different computers. The specified cluster size [N] will be truncated to the nearest lower power of 2. Entering a 'k' after the number will treat it as kilobytes instead of bytes, e.g. /f:32k to fake the size to 32 kilobytes.
h
Display usage in human readable format.
The usage numbers (both bytes and cluster formats) will be displayed in more easily to read numbers using suffix, like k, M and G (as in kilo-, Mega- Gigabytes) depending on the size of the number. Similar to the -h switch on some versions of "du".
i
Display disk info header only.
Basically a shortcut for the format specifier /F:0i, which causes all directory scanning to be skipped and only display the disk info header (free, total, filesystem etc.)
k
Report diskusage in kilo- bytes or clusters.
similar to the -k switch on some versions of "du".
m
Mark dirs/ext/users that qualify - Console version only
This option will add a new column to all output lists, named 'Q' (qualified). Qualified directories/extension/users will be marked with a * in this new column See
/Q switch .
r[:levels]
Display the disk usage recursively.
Optionally a level limit can be set to restrict the number of directory levels that are output. For example, /r:2 will display a maximum of 2 levels of directories beneath the path scanned. This switch disables the /S switch.
s
Silent mode.
Will only output the bottom line, i.e. the total usage of the scanned path.
S
Similar to the /s switch
But includes the configured fields and the disk info header. If this switch is given Zdu will only return the total usage of the specified path plus the available info about the disk.
t
Non-standard sTreams.
Only supported on NTFS disks. This will search every single file for non-standard streams and add the sizes of those to the file size. It will also add the streams column to the output, which will display the number of non- standard streams collected in the directory.
u:user
Report usage of file/dirs owned by a user (=[domain\]user)
Under Windows NT on NTFS disks Zdu can filter the usage calculation to only count the files which are owned by the specified user. If a domain is included in the user specification it must also match the file owner. Entering something like /u:.\haywire would count only files owned by the local user "haywire".
ud:user
Similar to the u:user switch
But also filters directories as well as files.
x:pattern
Exclude files that matches pattern
This follows the same pattern rules as the
filter .
F:format
Modifies the 'Usage by Directory' output from Zdu
format can be one or more of the following:
0 clear all
* set all
- disable the feature that follows this character (instead of add)
b (add) bottom line (total usage)
d (add) Directories column
e (add) Efficiency column
f (add) Files column
h (add) column Headers
i (add) disk Info header
p (add) Path column (relative paths)
P (add) Path column (absolute paths)
t (add) sTreams column
u (add) Usage column
By specifying any of the column fields or feature, it will be added unless the '-' preceeds it, e.g. enter /F:t and Zdu will add the streams column (labeled 'S') to the output, or entering /F:-d will remove the 'Dirs' column from the output. By default Zdu outputs Dirs, Files, Usage, Efficiency and Path columns. If all features are cleared (with '0' or - for all), the default output format will be used. If both 'p' and 'P' are specified the latter will be the one used. The order of the columns can not be specified.
I:arguments
Extra disk info header formatting - Console version only
m Multiple lines mode. Spreads disk info header on more lines and includes more fields.
M similar to 'm', but displays the drive letter on every line instead of a separate line.

Mopt:pattern

Matching options with regular expressions
opt can be one of the following:
xf  exclude files matching pattern
xd exclude directories matching pattern
if include files matching pattern
id  include directories matching pattern

pattern is a Perl-compatible regular expression (powered by PCRE).

All four patterns can be set at the same time on the command line.

Excluding patterns are processed first, so anything that matches either xf or xd will not be included in the usage data, even if if or id matches. Note that when patterns are not set, the exclude patterns (xf and xd) are treated as false matches, and include patterns (if and id) are treated as true. When a directory is excluded (either by matching the xf pattern, or by not matching the if pattern) all the files and directories it contain are of course also excluded.

Note: if pattern contains any characters interpreted by the command shell (e.g. the vertical bar), the whole command line argument will need to be quoted: "/Mif:patt|ern"

Olist:column
Specify sorting order for all Zdu's output lists
list  can be one of the following:
d Set sorting for 'Usage by Directory' list.
x Set sorting for 'Usage by Extension' list.
o Set sorting for 'Usage by Owner' list.
And subsequently the column values for each list:
For 'Usage by Directory' list:
d Directories
e Efficiency
f Files
p Path
t Streams
u Usage
For 'Usage by Extension' list:
c Count
u Usage
x eXtension
For 'Usage by Owner' list:
d Directories
f Files
o Owner
u Usage
Qname(+/-)value
Set qualifier for dirs/exts/users. - Console version only
This option sets qualifiers that is used by other options, e.g.
/m, /d and /R . Qualifers without those switches are useless. Several qualifiers can be entered on the command-line.
Available qualifiers are:
usage usage of directory/extension/user
filesusage usage of a directory's files (not sub-directories)   (only directories)
freespace free space on current drive
filecount file count   (only directories)
dircount directory count   (only directories)
efficiency efficiency percentage   (only directories)
streamcount file stream count (atleast 1)   (only directories)
streamusage usage of non-std streams   (only directories)

+ or - signifies whether the value represented by the qualifier (e.g. free space) should be larger(+) or smaller(-) than the <value> number.

<value> Integer number, specifying a size or a count. suffixes like, kilo, Mega, Giga, Tera and Peta can be used. Bytes/cluster unit depends on /c switch . Do note that the usage values are on a cluster basis, not on byte basis, which might make it seem to give a false positive sometimes.
Examples:
/Qusage+300
qualifier set when the directory size is more than 300 bytes(or clusters).
/Qfreespace-4G
qualifier set when the free space on the current drive is less than 4 Giga bytes(or clusters).
R:mode
Set return code of process depending on: - Console version only
q when ANY qualifier is met exit code=1, else 0 [default]

Note 1: When scanning multiple drives, the return code is 'accumulated' for all scans, meaning that if one scan qualifies the end result will be as such (return code = 1).
Note 2: The qualifiers only takes the total size and total counts resulting from the scan into account.
U:format
Selects one or more output lists
d Usage by Dir (default).
x Usage by file Extension.
o Usage by Owner (NTFS only).
Example:
/U:dx
This will enable both the 'Usage by Directory' and the 'Usage by extension' lists.

X:opt

Set extended options: - Console version only
db Database output mode (dbmode).
dbsep in dbmode - set field separator character. - implies /X:db
dbfixed in dbmode - set fixed field width (in characters). - imples /X:db
Example:

/X:dbsep=;
This will enable dbmode and set the field separator character to a semicolon. Database output mode implies /I:M as well.

Path Any valid path can be given as argument to zdu, only directories ofcourse. Zdu also supports UNC paths, i.e. the drive to be scanned does not need to be mounted. e.g.:

\\machine\share\...

Filter Zdu uses a normal globbing string matcher method. i.e. '?' mean excactly one character and '*' means any number (including zero) of any character.
Examples:

*.txt
filenames ending with ".txt " (including the file name ".txt ")
*one*
filenames that contains "one "
file?.txt
files with names like "files.txt", "file1.txt" etc.

7. KNOWN BUGS / LIMITATIONS & BUG REPORTING

Bugs:
Limitaions:
If you have found any bugs please e-mail me as soon as possible. I might not have found it yet. Or if you just like to give me some suggestions, or maybe some flames? Praise is accepted also ;-)

e-mail: haywire@fatalunity.com

8. FUTURE IDEAS

What Zdu will hopefully do in the future: What Zdu will NOT do/have: Suggestions? Mail me! (feedback is of the essence!)

9. DEVELOPMENT

Source code: ~90 kbytes (in ~4000 rows) (mixed C and C++)
Exe-file: ~84 kbytes (console) ~68 kbytes (GUI)
Build time: ~30 sec
Platform: Windows NT 4.0, Windows 2000, Windows XP
Software: MS Visual C++ 5.0, 6.0 and .NET
Hardware: P4-2260 512Mb 80G

10. AUTHOR

This little piece of software was written by a bloke named André Jonsson, that's me. I'm from Skellefteå, Sweden. Visit my homepage at http://haywire.fatalunity.com. All versions of Zdu is downloadable from there.

Initial programming of Zdu started way back in early 1995, because at the time there were no diskusage programs at all available for the DOS "platform" (that I knew of). As for release 2, the programming of the Win32 next-generation reincarnation began at the dawn of 1998, for no apparent reason :-) Can't keep my fingers away, I guess.

e-mail: haywire@fatalunity.com

11. VARIOUS

During development of Zdu the following music was listened to (in alphabetical order):

12. SPECIAL THANKS

Some special yahoos * goes out to the following: *) no relations to Yahoo.com.


Laws of Computer Programming:


																			(1) Any given program, when running, is obsolete.
																			
(2) Any given program costs more and takes longer.
(3) If a program is useful, it will have to be changed.
(4) If a program is useless, it will have to be documented.
(5) Any given program will expand to fill all available memory.
(6) The value of a program is porportional to the weight of its output.
(7) Program complexity grows until it exceeds the
capability
of the programmer who must maintain it.
(8) Make it possible for programmers to write in
English and
you will find the programmers cannot write in English.

																	

 

DON'T PANIC


 







WOW! You read all the way down here! If you meet someone else who managed to do the same, you better start a club or something because you are some rare people! :-)