This is a guide for using NTREE version 2.0, a very useful directory tree manipulation tool. NTREE is capable of many functions, including:
@Itemize{
Displaying directory listings recursively through the directory structure
Copying directory structures from one place to another
Deleting directory structures
Archiving directory structures into a single ARC file using the PD utility ARC
Totaling space used in a directory structure
Calling a DOS command for each file or directory (or both) in a directory structure
}
There are many switches and options for NTREE, and not all of them may be useful for a given NTREE mode. Each major NTREE command will be taken in turn, along with the switches that are appropriate with it.
@Section(NTREE command syntax)
The basic format of an NTREE command is as follows:
The only required argument is a single directory path. Directory paths specified may be in the following formats:
\directory\directory...
drv:directory\directory...
drv:\directory\directory...
directory\directory...
The current drive and directory are inserted into the directory strings as appropriate.
Switches can be either single character or multi-character. The multi character switch names are typically used by switches that aren't used so frequently. Switches may be placed anywhere in an NTREE command (with one exception - see the CALL command)
A wildcard string may be used on the first pathname. For example, to display all text files on the hard disk one might use:
NTREE/A C:\*.txt
If a wildcard is placed on the second pathname, it is removed and ignored.
For those familiar with the old version of NTREE, you may notice that there is a pause before the program actually begins performing the command. NTREE now reads the names of the directories it will be working with before it begins. It is also capable (more or less) of telling when two trees intersect, avoiding the problems of copying a tree onto itself.
@Section(Directory Display operation)
NTREE's default mode is for directory displays. That is, if you invoke NTREE with just a pathspec argument, all directories in the tree below the specified path will be written to stdout.
For example:
NTREE C:\
will display the names of all the visible directories to stdout.
The switches that operate with the directory display are as follows:
@description{
/A@/displays the names of the files in the directories (instead of just the directory names)
/DIR@/Displays the string "<DIR>" next to a filename if it is a directory. This also causes directory names to appear in /A listings.
/I@/Displays information about the files (size, creation date). This should usually be used with the /A switch.
/H@/includes hidden files and directories in the search.
}
@Section(Copying directory structures)
NTREE's major purpose is to copy directory structures from place to place. The main syntax for copying trees is:
NTREE/C path1{wild} path2 {moreswitches}
So, to copy all the "C" files to the floppy from the hard disk, one would type:
NTREE/C C:\*.C A:\
The switches that apply to the copy function are:
@Description{
/H@/Copy hidden files too.
/Q@/Query before copying a file
/V@/Turn on DOS VERIFY switch while copying
/O@/Overwrite existing files
/U@/Copy only source files with archive bit set
/DATE@/Copy only source files with later dates than corresponding destination files
/YES@/Answer "YES" automatically to prompt for overwriting files
}
@section(Deleting trees of directories)
NTREE can also destroy an entire tree of directories. The syntax for this is:
NTREE/D path1{wild}
The switches that are used here are:
@Description{
/YES@/Answer "YES" automatically to confirmation question
/H@/consider hidden files in search
/V@/Turn on DOS verify switch
}
@Section(Displaying space usage of a structure)
NTREE can tell you how much disk space is used by a particular structure on your disk. The syntax is:
NTREE/T path{wild}
You can use a wildcard to only include certain files in your scan. NTREE will display information in a format similar to the following:
Tree D:\*.* contains 74 files in 4 directories,
1061894 bytes (1037K)
2114 clusters for drive D: (1057K)
2114 clusters for floppy drive: (1057K)
The only useful switch here is /H, which causes NTREE to count hidden files in with the visible ones.
The number of clusters and amount of space are given both for the device the files were stored on, and the typical floppy drive. This is useful for judging wether a collection of files will fit on a floppy.
@Section(Archiving a collection of directories)
The public domain utility ARC is very useful for compressing a collection of files for archival, but it cannot deal with directory trees. NTREE can call ARC to pack an entire structure into a single ARC file. Suppose you had directories as follows:
D:\
D:\INCLUDE
D:\INCLUDE\SYS
D:\LIB
by issuing the command:
NTREE/ARC D:\ DRIVED.ARC
NTREE would create nested ARC files in the file DRIVED.ARC:
in DRIVED.ARC:
(other files in D:\ directory)
INCLUDE.ARC
(other files in INCLUDE directory)
SYS.ARC
(files in SYS directory)
LIB.ARC
(files in LIB directory)
There is no way at present to undo this, (except by hand) A future NTREE will have a command to undo an ARC'd structure.
NTREE does not delete the tree as it proceeds. You must have enough space on the device to hold the original files, the archives, and the temporary space used by ARC's cruncher.
@Section(The NTREE call facility)
Sometimes it's not enough for NTREE just to be able to copy or delete structures. Instead of building in all sorts of fancy tree manipulation routines, NTREE has a facility for calling existing MS-DOS programs throughout the directory tree.
The switches /CALL, /BEFORE, and /AFTER MUST be followed by a template string. The position of the switch is important for determining the string's function. Template strings should be in quotes, and separated from the switches and other parameters by spaces.
The /CALL template is used for each file in the directory tree. The /BEFORE template is used before enumerating the files in a directory (before the /CALL template is invoked). Similarly, the /AFTER template is used AFTER the files have been enumerated and all /CALLs have been done.
There are a number of special macros that may be embedded in a template. These macros are:
@Description{
$$@/The dollar-sign character
$s@/The source filename (made with first pathname)
$d@/The second filename (made with second pathname)
$c@/The current working directory
$f@/Just the filename portion of the file (no directory path)
$b@/The size of the source filename
$g@/The greater-than sign character (>)
$l@/The less-than sign character (<)
$p@/The pipe character (|)
$q@/The double-quote character (")
}
For example, to type all the C programs on the hard disk, the following NTREE command could be used:
NTREE C:\ /CALL "type $s"
To make a file with DOS "DIR" listings for an entire disk, you could use:
NTREE C:\ /BEFORE "dir $s $g$gC:\master.dir"
You could compare two disks, file by file, with:
NTREE A:\ B:\ /CALL "fc $s $d"
There are a few switches that work with this command:
@Description{
/H@/Do hidden files too.
/BAT@/Do not execute DOS commands, simply write them to stdout. If you redirect NTREE's output to a file, you can generate batch files this way.
/V@/Turn DOS Verify flag ON
}
Since the DOS commands are executed via system(), it is a good idea to keep a copy of COMMAND.COM on your RAM disk. Because system() is used, batch files may be also executed in a command.