1. Removing Files with the Del and Erase Commands
The Del and Erase
commands are functionally equivalent. The two commands started with
different versions of DOS, but they perform the same task now: erasing
files that you no longer need from the hard drive. Unlike the deletion
that Windows performs, the files don't end up in the Recycle Bin; the
deletion is permanent. These commands use the following syntax:
DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
The following list describes each of the command line arguments.
names
Defines the
file or directory names to remove from the hard drive. You can use
wildcard characters to specify the filenames. See the "Working with
Wildcard Characters" sidebar for details. Deleting a directory also
deletes all of the files that the directory contains. Consequently,
these commands can be exceptionally destructive.
/A
Deletes files or directories based on their attributes.
NOTE
Server Core adds the L attribute for reparse points and the I attribute for nonindexed files. The I
attribute is a little tricky because you see it when the file isn't
indexed versus when it has the required feature such as when you use the
other attributes. These new attributes help you work with new file
system features.
/F
Forces the deletion of files marked with the read-only attribute. Normally, the commands prompt the user to delete such files.
/P
Prompts the user
to delete every file. This command line switch provides a safety
factor, but also increases the time required to delete files.
/Q
Deletes
files based on a wildcard specification without prompting the user
first. Normally, the utilities prompt the user before deleting all of
the files in a directory.
/S
Deletes the
specified files from all subdirectories. This command comes in handy
when you want to remove all of the files with a given name on a hard
drive. Windows often creates multiple copies of files; locating them all
can be difficult.
You might wonder how you
can make your use of commands and utilities even more efficient. Most of
these utilities will let you work with multiple files at once, but you
need to know the secret of specifying multiple files. Wildcard
characters let you specify a group of files or directories without
naming each file or directory individually. There are two standard
wildcard characters: * and ?. The asterisk (*) specifies any number of characters, while the question mark (?)
specifies a single character. You can use the two wildcard characters
in combination to create complex file specifications to locate just
about any file.
Most people are familiar with the * character. Typing Dir S*.TXT at the command line locates every text file in the current directory that begins with an S. However, you can use the * in any location. For example, typing Dir *S*.TXT at the command line would locate any text file that contains an S in any part of its name. Likewise, typing Dir *S.TXT would locate any text file that contains an S at the end of its name. You can also use the * for the file extension. Typing Dir S.* locates any file with S as a filename, but with any file extension.
The ? is far more selective than the * and many people fail to recognize its value. For example, typing Dir S??.TXT
at the command line will locate any text file with three characters in
its filename that begins with the letter S. Consequently, this command
will locate SUB.TXT and SUN.TXT, but not SUBST.TXT or RUN.TXT (notice that even though RUN.TXT contains three letters, it doesn't begin with an S). Like the *, you can use the ? wildcard character anywhere in the filename. For example, you can type Dir *.EX? to locate both compressed and uncompressed executable files in the current directory. Without the selectiveness of the ? wildcard, you might end up with files that you didn't really want to find.
2. Compressing Files with the Diantz and MakeCab Utilities
Most people assume that
you need to use a third-party compression product to create file
archives with Windows. Of course, the ZIP file format is the most
popular solution, but there are other alternatives, such as the RAR
format supported by WinRAR (http://www.rarlab.com/).
However, you can use the cabinet (CAB) file format without buying a
third-party utility. The only utility provided with newer Windows
versions is MakeCAB. An older utility, Diantz, appears on the hard
drive, but it calls MakeCAB. The CAB file appears in many places in
Windows. For example, you'll find that Microsoft uses CABs to compress
many application files on setup disks. In fact, there's even a Microsoft
Cabinet Software Development Kit discussed at http://support.microsoft.com/kb/310618/. This utility uses the following syntax:
MAKECAB [/V[n]] [/D var=value ...] [/L dir] source [destination]
MAKECAB [/V[n]] [/D var=value ...] /F directive_file [...]
The following list describes each of the command line arguments.
source
Specifies the name
of the file you want to compress. Unlike many Windows utilities, you
can't use wildcards to create a file specification. Provide a source
filename when you want to compress a single file or a directive file
when you want to compress multiple files.
destination
Specifies the name
of the destination file. When you specify a source file without a
destination filename, the utility creates a file with an underscore that
replaces the last letter of the file extensions. For example, when you
type MakeCAB NewFile.txt and press Enter, the utility produces an output file with the name NewFile.tx_.
/F
directive_fileSpecifies the name of a
Diamond Directive File (DDF) that contains instructions for creating
complex archives. You can specify multiple files, some of which are
compressed and others that aren't. Using a DDF, you can create an
archive that spans multiple disks. The MAKECAB.DOC file in the \cabsdk\DOCS directory of the Microsoft Cabinet Software Development Kit tells how to create a DDF.
/D
var=valueDefines
variable settings for the MakeCAB utility. These variables control how
MakeCAB works. For example, you can tell MakeCAB to create an archive
without compressing any of the files by using the COMPRESS=OFF
directive. You can find a complete list of variables and their
associated values in section "4.2.2. Variable Summary" of the Microsoft
Cabinet Software Development Kit.
/L
dirSpecifies the directory to use to store the archive. The default setting uses the current directory.
/V
[n]Specifies
a level of verbosity for the compression messages. The utility accepts
any value between 1 and 3. The default setting is 1, which provides
major messages and a completion message. The second verbosity level
provides a list of files in the archive as the utility compresses them.
The third verbosity level includes compression levels and other
activities.