DOS stores a default directory for each drive. When a path is specified with a drive specification only, such as D:, it is completed with this default directory of that drive to construct the absolute path to be used.
The drive is a single letter from A through Z followed by a colon :.
The remaining part of a path consists of similiar components
delimited by a single backslash \. The last component
is also called filename. Each of these components may be formed of
a name, up to eight characters long, and an extension, up to
three characters long. Both parts are delimited by a single dot
.. Although the extension may be absent, the filename
must have at least one character.
Note: The term filename is not limited to files
in the usual sense, but may apply to any name visible in a directory,
such as subdirectories and volume labels, as well.
To ease the way to enter a path the user may specify a relative path, rather than an absolute one. In such path one or more components may be missing:
Examples, assume the current directories of
| Drive | Current Directory |
| C: | \FREEDOS\HELP |
| D: | \TEMP\TEXT |
Path specifications that do not conform to above mentioned format lead to various different behaviour of the various programs, because there is no standard to scan, parse and interprete such patterns. Problems include:
Note: The special directories . and .. are no phantom directories or virtual entries, but standard entries of every directory except the root directories. These entries help crash recovery tools, such as CHKDSK or SCANDISK, to find errors within the directory structure and restore it to a valid file tree. Therefore a common assumption that a tripple dot ... directory means parent-of-parent is incorrect, though, might be supported by certain programs.
Some commands do accept long option names, where a complete word identifies the option rather than a single character, e.g. /MSG.
Some option may be used in conjunction with an argument. The argument is appended to the option with one colon ":" or one equal sign "=", for instance: /A:hr or /P=fdexec.bat.
Multiple options without argument maybe merged together
as a single option with embedded slashes, e.g.
/W/S, instead of /W /S.
An option with argument may be the last one of such merged options.
Options without arguments enable or disable certain features. Therefore,
those options are sometimes called boolean options or flags.
Boolean options may be prefixed by a minus "-"
sign, in order to disable or turn off the option; otherwise, the option
is enabled.
Without user invention a boolean option is disabled by default.
However, some commands allow the user to change the default settings of
certain options, e.g. COPY and DIR.
If the input stream is redirected to a file or device, instead of polling the keyboard and request the user to interactively enter characters via the keyboard, those characters are read from the file or device. Usually these programs terminate when the file has been read wholely.
If the output stream is redirected to a file or device, instead of issuing the information onto screen, it is dumped into the file or device. Per convention each program has two output streams: one (called standard output) to issue normal information and one (called standard error output) for error messages the user should not miss.
Redirections are specified on command line and effect exactly that
command invoked herein, regardless if the command is an external or
internal one, an alias or batch script. The utter exception is the FOR
command, which requires that the redirection is to apply to the command
specified behind the DO keyword rather than FOR itself.
If more than one redirection is specified on the command line and
they effect the same stream (input, output, or error), the rightmost one
superceed any previous one.
Redirections are syntactically specified like this:
operator target
operator ::= '<' | '>' [ '>' ]
target ::= file | device
Although it is not relevant where the redirections are placed on the
command line, it is common praxis to place them at the end of it.
The operators have the following meaning:
| Operator | Redirection |
|---|---|
| < | Input stream |
| > | Output stream; target file is overwritten |
| >> | Output stream; output is appended to target, if it already exists |
Another form of redirection is piping. Hereby, the output stream of one command is connected to the input stream of another command. Pipes can combine any number of commands this way. Because DOS is no multitasking system, pipes are simulated by spawning the first command with an output redirection capturing the issued information into a temporary file and then the second command with an input redirection from that very same temporary file, on completation of the second command the temporary file is deleted.
Consider the batch file BATCH.BAT:
@ECHO OFF ECHO 1 ECHO 2 >out_2 ECHO 3which is invoked via:
FreeCOM supports the standard DOS wildcards as supported by the DOS kernel itself:
| Wildcard | Meaning |
|---|---|
| * | Any remaining body, except a dot (.) |
| ? | Any character, except the dos (.); acts as *, if the last character |
Examples:
| Pattern | Meaning |
|---|---|
| *.* | Any file in the current directory |
| c:*.* | Any file in the current working directory of drive C: |
| * | Any file without an extension. Some commands, such as DIR, interprete a single * as *.* |
| a*.* | Any file, which first character is an A, neither the remainder of the filename nor the extension of the file matters |
| a?.* | same as above |
| a???.* | same as above |
| a*b.* | same as above |
| a?b.* | Any file, which first character is an A and the third one is a B; the remaining characters nor the extension matter |
| file?.txt | All files, which first four characters are FILE and which extension is equal to TXT |
| \scripts\*.pl | Any perl file in the directory \SCRIPTS located in the root directory of the currently selected drive |
Warning: There are common mistakes about wildcards, as DOS has less functional wildcards than other systems, in particular:
By default, before executing a line, it is displayed onto the screen,
in order to prevent this, one can turn off this feature with the ECHO command
or prefix each line with the Ad sign (@), e.g.:
ECHO This line is displayed
@ECHO This line is NOT displayed
Commonly batch scripts start with the line:
@ECHO OFF
in order to turn off to echo each line furtherly in the script
processing and to suppress to echo the line itself, too.
Lines starting with a colon (:) label this particular script
line, in order to be jumped to with the GOTO command, e.g.:
@ECHO OFF
IF "%1"=="" GOTO useage
ECHO argument1=%1
ECHO argument2=%2
ECHO argument3=%3
GOTO ende
:useage
ECHO Useage: %0 {arguments}...
:ende
When the shell reaches the end of the file, the batch processing terminates.
The errorlevel of the last spawned external command remains unchanged.
Because the shell closes the batch script and re-opens it each time a
command, for both internal and external ones, is invoked, one can savely
replace floppy disks during a batch processing, e.g.:
@ECHO OFF
ECHO Copying disk1
COPY files\*.* C:%1
:disk2
PAUSE Insert disk #2, then hit ENTER
IF NOT EXIST disk2 GOTO disk2
ECHO Copying disk2
COPY files\*.* C:%1
:disk3
PAUSE Insert disk #3, then hit ENTER
IF NOT EXIST disk2 GOTO disk3
ECHO Copying disk3
COPY files\*.* C:%1
ECHO Copying done.
When a batch file is invoked within another batch file, the previous ones
does not proceed once the called one terminates, regardless of the
nesting level; this is called chaining, one chains to another
program and does not intend to come back. To have a batch script behave
like an external program in this regard, it must be invoke via the
CALL command, e.g.:
@ECHO OFF
ECHO %0 - line 2
CALL batch2
ECHO %0 - line 4
and BATCH2.BAT:
ECHO %0 - line 1