List of commands and features of FreeCOM:



ALIAS - Display or change an alias

Requirements: FEATURE_ALIAS

Synopsis

  1. ALIAS
  2. ALIAS name '=' [ «string» ]

The first format without any argument displays all defined aliases.

The second format assigns the specified string to the alias with the specified name. If the string is empty, the named alias is removed.

Once an aliase is defined, a command line of the form: name { argument }
is replaced by: <> { argument }
This mechanism is called alias expansion, because the alias name expands to the specified «string». To prevent alias expansion the command must be prefixed by one asterisk, e.g.: *name arguments

Examples

Example: 1

ALIAS dir=dir /w
dir
displays short directory listing from now on.

Example: 2

ALIAS
displays all currently defined aliases, e.g.:
DIR=dir /w
in this case.

Example: 3

ALIAS dir=
removes the previously defined alias dir, thus, DIR displays the long output as by default again.


BEEP - Issue a Beep

Requirements: CMD_BEEP

Synopsis

BEEP

Issues a beep.
At this time FreeCOM supports audible beeps only.


BREAK - Display or Set Extended Break Checking

Requirements: CMD_BREAK

Synopsis

BREAK [ ON | OFF ]

Displays or sets the Extended Break status.

By pressing ^Break or ^C (Control-Break or Control-C) an user may signal the currently running program to halt. Most programs will abort to the prompt, but some may decide to just cancel the current action, but remain active.

DOS checks for ^Break/^C (Control-Break or Crontrol-C) each time a program issues a console input/output request. When Extended Break checking is enabled (ON), DOS checks for ^Break each time a program issues a request.


CALL - Call a Nested Batchfile or Program

See also: LOADFIX, LOADHIGH
Optional requirements: FEATURE_KERNEL_SWAP_SHELL

Synopsis

  1. CALL program [ «arguments» ]
  2. CALL /S program [ «arguments» ]

Calls a program or batch script.

If the program is a batch script, that means it has the extension .BAT, CALL nests the batch script within the already running one. Without CALL the invoked batch script would terminate all already running batch scripts.

If present, the arguments are passed unchanged to the invoked program.

Options

Unless stated otherwise all options of this command do follow the standard rules for options.

Note: In the future to swap FreeCOM out of memory during the execution of an external program will be the default behaviour.


CD - Change current directory of a drive

See also: CDD, CHDIR, DIR, DIRS, MD, MKDIR, PUSHD, RD, RMDIR
Requirements: CMD_CHDIR
Optional requirements: FEATURE_LAST_DIR

Synopsis

  1. CD
  2. CD [ drive ':' ] path
  3. CD '-'
CD is 100% compatible with the CHDIR command; there is no difference -- beside the spelling -- between them.

The first variant shows the current working directory as absolute path.

The second variant changes the current directory of the given drive. If no drive is specified on command line, the current directory of the currently selected drive (disk) is changed. This command does not change the currently selected drive in opposite to CDD!

The third variant changes back into the last visited directory and drive. The commands CD, CHDIR, CDD, and PUSHD save the current working directory before performing the specified directory change; the command CD '-' restores this saved directory. This command is available only, if the feature LAST_DIR has been enabled during the compilation of FreeCOM.

Options

There are no options for this command.

Examples

Example: 1

CD \freedos\help
Changes the current working directory of the currently selected drive to the path \FREEDOS\HELP.

Example: 2

CD c:\freedos\help
Changes the current directory of drive C:.

Example: 3

Assuming the current working directory is \FREEDOS\HELP and the currently selected drive is C:. CD
Displays C:\FREEDOS\HELP

Example: 3

The command sequence, provided the first two worked successfully:
CD \FREEDOS\HELP
CD ..
CD -
changes first into the directory \FREEDOS\HTLP, then into its parent directory, which is \FREECOM. And finally CD - changes back to \FREEDOS\HELP, because this was the previous directory before previous CD-like command.

Because CD - saves the previous directory, too, any subsequent: CD -
will switch between these two directories; until another directory is changed to.


CDD - Changes the current working directory

See also: CD, CHDIR, DIR, MD, MKDIR, PUSHD, RD, RMDIR
Requirements: CMD_CDD

Synopsis

  1. CDD
  2. CDD [ drive ':' ] path
  3. CDD '-'
The behaviour of CDD is similiar to the CD command, but it always changes both the currently selected drive and the current directory, thus, it changes the current working directory.

For further details please see the CD command.


CHDIR - Change current directory of a drive

This command is 100% compatible to CD, please see there


CLS - Clear screen

See also: ECHO, TYPE
Requirements: CMD_CLS

Synopsis

CLS
Clears the screen and resets the character colours to white on black.


COPY - Copy one or more files to another location

See also: DEL, REN
Requirements: CMD_COPY

Synopsis

  1. COPY [{ option }] source [{ option }] target [{ option }]
Copies the source file into the target file. See also: \REF{wildcards}

Options

Unless stated otherwise all options of this command do follow the standard rules for options.

Arguments


CTTY - Change TTY (console)

Requirements: CMD_CTTY

Synopsis

CTTY device
With this command the console device can be changed. A console device performs all basic input and output operations. This change is more complete than
IO-redirections, because they might not catch all output, for instance the error messages. See example 3 below.
Because the console is a bidirectional virtual device, meaning it is to perform input and output, the specified device must not a unidirectional device, such as PRN.

To specify a second argument on the command line of FreeCOM has the same effect.

Attention: This command is to effect the whole system, not only FreeCOM itself; so the effect of CTTY does not only depend on the implementation status of FreeCOM, but on the DOS kernel, too.

Also, some programs access the screen or keyboard directly, rather than using the DOS functions; these programs are not effected by CTTY.

Examples

Example: 1

CTTY aux
Changes the console to the AUX: device, which is usually the first serial communication port COM1:. If this line is connected to a terminal or a terminal emulator, the system can be controlled from the terminal by now.

Example: 2

CTTY nul
any command sequence
CTTY con
The first command discards any output. If a program attempts any input operation, it gets none. Some programs may not handle such situation correctly.
So, any output, even error messages, are discarded during the command sequence.
The second command changes the console back to the screen/keyboard pair.
To display a string onto screen or read from keybord the usual I/O-redirections may be used, for instance:
  • ECHO This line appears on the screen >CON
  • PAUSE <CON
    This PAUSE command will get its input even within the "CTTY nul" environment.


DATE - Display or set current date

See also: TIME
Requirements: CMD_DATE

Synopsis

  1. DATE [ /D ]
  2. DATE [ /D ] date
The first variant displays the current system date, then enters a loop prompting the user for a new date. The loop terminates, if the user entered a valid new date or just pressed the ENTER key.

The second variant does not display the current date and tries to change the date to the specified date. On success the command terminates, otherwise enters the loop explained above.

The individual portions of a date may be separated by at least: dots ., forward slashes / or dashes -. Other nationally used characters may be supported, too.
DATE will support partial formats:

  • A single numnber: specifies the day only.
  • Two numbers: specifies the day and the month in the order used by the national date format, which is MM/DD for American and Japanese and DD/MM for European format.
  • Three numbers: specifies a full date including day, month and year in the order suitable for the national date format, which is:
    • MM/DD/[CC]YY: for American,
    • DD/MM/[CC]YY: for European and
    • [CC]YY/MM/DD: for Japanese format.
    If the year portion is less than 100, the century is assumed to be 1900, if it is greater or equal than 80; otherwise the century is 2000.

    Note: Some European countries introduced the so-called business date in 1996 or so, which is the same as the Japanese format; it makes sorting of literal dates a lot easier. If FreeCOM will or will not support it, will depend on the NLS used by DOS.


Symbolical names of monthes are not support (yet).

Options

All options must precced any argument.

/D prevents from prompting the user.

  1. In variant 1, the date is displayed only.
  2. In variant 2, the date is tried to be changed, but the loop is not entered on failure.

Examples

Example: 1

DATE /D
Just display the current system date.

Example: 3

DATE 2/1/00
Sets the current date to 1st February of 2000.


DEL - Delete files

See also: DIR
Requirements: CMD_DELETE

Synopsis

DEL [{ options | pattern }]
Deletes files, if pattern matches a directory, all files within this directory are deleted.

When all files are to be deleted, a warning prompt is issued.

Options

Unless stated otherwise all options of this command do follow the standard rules for options.
  • /P: Prompts the user before delete a file.

Examples

Example: 1

DEL FILE1.EXT FILE2.EXT
Deletes the files FILE1.EXT and FILE2.EXT.

Example: 2

DEL /P *.bak
Deletes all files with extension BAK, but prompts the user for each single file before deleting it.

Example: 3

DEL.
Deletes all files within the current directory.


DIR - Displays the contents of the directory

See also: CHDIR, MKDIR, RMDIR
Requirements: CMD_DIR

Synopsis

DIR [{ options | pattern }]

DIR displays the contents of direcories and/or the attributes of files, whatever the pattern specifies. If no pattern is specified on command line, the current working directory is displayed. The actual information displayed depends on the specified options and is explained below.

A pattern may contain wildcards, which are expanded against both files and directories. To specify a directory is essentially equal to write: directory\*.*.

Unlike options patterns are performed in sequence, that means that if two patterns are specified, first all entries matching the first one, then all entries matching the second one are displayed; instead of to display the matching entries intermixed.

Options

Unless stated otherwise all options of this command do follow the standard rules for options.
  • /A: (All) Wildcards are matched against System and Hidden files, too.
  • /B: (Bare) Displays the lines with the information of files and directories only. The ones displaying the volume label, the serial number, totals etc. are suppressed. In combination with /S the absolute path of the files is displayed.
  • /L: (Lower-case) Filenames are displayed in lower-case letters rather than capitol ones.
  • /P: (Page) Page the output -- pause the display after issuing one screen-full.
  • /S: (Subdirectories) Recursively display directories.
  • /W: (Wide) Displays five filenames per line and suppress the information about the file size, date etc.
  • /Y: (Year) Displays a 4-digit year, rather than just two digits.

Examples

Example: 1

DIR
Displays the contents of the current directory, but ignore System and Hidden files. The output may look like this:
!!todo!!

Example: 2

DIR a* bb* *.txt
First displays all files, that begin with the letter A; then all files, that begin with two letters B, are displayed and at last all files with the extension TXT.

Example: 3

DIR /w a* b*
DIR a* /w b*
DIR a* b* /w
Because the position of options is not significant, all these examples behave the same way and display the matching files in wide or also called short form, which may look like this:
!!todo!!

Example: 4

DIR /as ..
DIR .. /a/s
DIR /s .. /a
Because DIR processes all options globally and single-character options may be joined together, all the above examples behave the same way and recursively display all files beginning from the current directory's parent directory including all System and Hidden files.


DIRS - Display the directory stack

See also: CD, CHDIR, POPD, PUSHD
Requirements: CMD_DIRS

Synopsis

DIRS
Displays all directories stacked with the PUSHD command.


ECHO - Displays a string onto screen

See also: TYPE
Requirements: CMD_ECHO

Synopsis

  1. ECHO [ ON | OFF ]
  2. ECHO «string»
  3. ECHO.
When executing a batch script each line is displayed to the console before executing it by default. The first variant of ECHO enables or disables this behaviour. To disable echoing the commands is equal to prefix each line of a batch script with the Ad-symbol @.
If ECHO is invoked with no argument at all, the current echo status is displayed.
When entered on an interactive command line the echo status controls whether or not the PROMPT string is displayed.

The second variant displays the specified «string».
Note: Because of variant 1 «string» may not expand to the single words ON or OFF without another character.

The third variant displays an empty line. No space must be placed between the dot and ECHO.

Examples

Example: 1

ECHO
Displays the current echo status, e.g. responding:
ECHO is on

Example: 2

@ECHO OFF
Disables the echo status. Because the Ad-sign @ disables the echo status right for this line, this command disable echoing all the next lines of a batch script and is not echoed to the console itself. It is, therefore, best placed in the first line of a batch script.

Example: 3

ECHO Just a text
Displays Just a text


ERASE - Delete files

This command is 100% compatible to DEL, please see there


EXIT - Terminate shell

Synopsis

EXIT
Terminates the currently running shell, unless it had been started with the /P option.


FOR - Repeat a command

Requirements: CMD_FOR

Synopsis

FOR '%' letter IN '(' { word | pattern } ')' DO «any command»
Executes «any command» for several values assigned to the variable letter. The values are read strictly left to right from the words and patterns enclosed in parenthises; where patterns are words containing wildcards and are replaced by all matching filenames.

Any occurence of a percent sign % and the specified letter is replaced by the current value of the FOR loop.

Warning #1: Unlike most commands I/O-redirections are passed forth to the command instead of to apply them to FOR itself.
Warning #2: Due the syntactical problem that the FOR variable is specified as '%' letter, which is also a legal start of an environment variable, the following kludge had been included to support FOR and its special variables:

  • You can use as many percent character as you wish as long as you use exactly the same number for a particular FOR variable.
  • Before any environment variables are expanded, the command line is checked for the skeleton specified within the synopsis (there must not be specified no redirection between the FOR and DO keywords), if it is found, the FOR command is executed without expanding any environment variables -- they get expanded each time the command is invoked.
  • Known Bug: Otherwise any environment variables are expanded and, if it happens that a valid FOR command is found now, the environment variables within the command are expanded a second time. In this case the I/O redirections are applied to FOR, too, instead of passing them forth to the command.
  • FOR commands as part of the command of CALL, IF, and FOR itself are never found before expanding the environment variables.

Examples

Example: 1

FOR %z IN (*.*) DO copy %a a:
Performs a COPY xyz A: command for each file in the current directory. Its behaviour is equal to COPY *.* A:

Example: 2

FOR %z IN (a?b*.TXT) DO CALL batch arg %z
Executes the batch script batch.bat for each file matching the pattern A?B*.TXT located in the current directory. Within the script, the automatic variable %1 always expands to the constant argument arg, whereas %2 expands to the filename of the current loop.

Example: 3

FOR %a IN (1 2 3 4 5) DO ECHO %a
Is equal to the command sequence:
ECHO 1
ECHO 2
ECHO 3
ECHO 4
ECHO 5
Because these words do not contain no wildcards, they are not matched as filenames.

Example: 4

FOR %g IN (1 2 3*) DO ECHO %g
Performs the commands:
ECHO 1
ECHO 2
and the ECHO command for each file in the current directory, that has no extension and which name starts with the digit three.


GOTO - Goto label

Requirements: CMD_GOTO

Synopsis

GOTO [ ':' ] label
Normally all commands of a batch script are executed in the sequence in which they are appear with the script.
GOTO controls the command flow by unconditionally jumping to the specified label; the commands following that label will be executed then. A label is written as a colon in the first column of a line and the name of the label immediately behind. If FreeCOM hits a label in the normal flow, it is ignored completely, even any redirection characters are ignored.

The label must be located in the same script file as the GOTO itself, if it appears more than once, the first occurance takes precedence.

Conditional jumps can be contructed with help of the IF command, see example 2.

Examples

Example: 1

GOTO ende
Jumps the to label :ende

Example: 2

IF "%1"=="" GOTO emptyCommandLine
Jumps to label :emptyCommandLine, if no argument had been passed to the batch script. For instance:
@ECHO OFF
IF "%1"=="" GOTO error
REM do something sane here
GOTO ende

:error
ECHO You must pass an argument to me!

:ende


IF - Conditional execution of a command

Synopsis

  1. IF EXIST file command
  2. IF ERRORLEVEL number command
  3. IF string '==' word command
  4. IF quoted-string '==' quoted-string command

Options

Unless stated otherwise all options of this command do follow the
standard rules for options.

Examples

Example: 1


LOADFIX - Load an external program above the first 64KB memory

See also: CALL, LOADHIGH

Synopsis

LOADFIX program [{ argument }]
Loads and executes an exepacked program, that would abort execution with the error message "Packed file corrupt" otherwise.

Example:

LOADFIX program.exe


LOADHIGH - Load an external program into high memory

See also: CALL, LOADFIX

Synopsis

LOADHIGH [{ option }] program [{ argument }]
Loads and executes an external program in high memory, also called UMB. This command is used to load TSRs, such mouse drivers, into the upper memory to conserve the conventional memory for programs.

Example:

LOADHIGH lmouse.com


MD - make directory

See also: CHDIR, MKDIR, RMDIR
Requirements: CMD_MKDIR

Synopsis

MD path

Options

Unless stated otherwise all options of this command do follow the standard rules for options.

Examples

Example: 1


MEMORY - Display the internally used memory

Requirements: CMD_MEMORY

Synopsis

MEMORY

Displays the useage of internal memory of FreeCOM.

Examples

MEMORY
may display this:
Environment segment    : max  1200 bytes; free     8 bytes
Context segment        : max  2304 bytes; free  2252 bytes
        Aliases        : limit  1024 bytes, current     5 bytes,     0 items
        History        : limit   256 bytes, current    34 bytes,     2 items
        Directory stack: limit   256 bytes, current     5 bytes,     0 items
        Last dir cache : used      0 bytes,     0 items
        Swapinfo       : used      0 bytes,     0 items
Heap                   : free 482080 bytes
  • The Environment segment is the storage area, the environment variables are storred in. It may be changed passing the /E option to FreeCOM.
  • FreeCOM stores several internal information into the Context segment; the aliases - modified by the ALIAS command -, the history - displayed using the HISTORY command, accessed by pressing the cursor Up/Down keys on command line -, the directory stack - displayed with the DIRS command and accessed using the PUSHD and POPD commands -, the last directory - accessed with the CD - command -, and, finally, some internal command used by the low-level swap interface of FreeCOM.
  • The heap is the storage area FreeCOM can allocated memory from itself. This value is useful for FreeCOM developers mostly.
  • max specifies the maximum amount of bytes allocatable within this storage area.
  • free specifies the unused bytes within this storage area.
  • limit specifies the maximum amount of bytes allocatable for the particular information within the area.
  • current specifies the amount of bytes currently allocated for the particular information.
  • items specifies the number of items storred for the particular information, e.g. how many directories have been pushed onto the stack using PUSHD.


MKDIR - Make directory

This command is 100% compatible to MD, please see there


PATH - Display or set the search path

Requirements: CMD_PATH

Synopsis

PATH [ '=' ] { path : ';' }
PATH

Options

Unless stated otherwise all options of this command do follow the
standard rules for options.

Examples

Example: 1


PAUSE - Pauses batch file execution

Requirements: CMD_PAUSE

Synopsis

  1. PAUSE
  2. PAUSE «string»

Pauses the batch file execution until a key is pressed.

PAUSE prompts the user with the specified string or, if none is specifed, "Press any key to proceed"

Examples

Example: 1

PAUSE
Just pauses the execution.

Example: 2

PAUSE Execution paused, press any key to proceed ...
Pauses execution displaying this string.

Example: 3

PAUSE >nul
Pauses execution, but does not display any prompt.


POPD - Change back to the last pushed directory

See also: CD, CDD, DIRS, POPD
Requirements: CMD_CDD,CMD_POPD

Synopsis

  1. POPD
  2. POPD '*'

Options

Unless stated otherwise all options of this command do follow the standard rules for options.

Examples

Example: 1


PROMPT - Display or set the shell prompt

Requirements: CMD_PROMPT

Synopsis

PROMPT
PROMPT [ '=' ] prompt

Options

Unless stated otherwise all options of this command do follow the
standard rules for options.

Examples

Example: 1


PUSHD - Push the current working directory onto the directory stack

See also: CD, CDD, DIRS, POPD
Requirements: CMD_CDD,CMD_PUSHD

Synopsis

PUSHD directory

Options

Unless stated otherwise all options of this command do follow the standard rules for options.

Examples

Example: 1


RD - Remove directory

See also: CD, MD
Requirements: CMD_RKDIR

Synopsis

RD path

Options

Unless stated otherwise all options of this command do follow the standard rules for options.

Examples

Example: 1


REM - Marks comments or remarks in batchfiles

Requirements: CMD_REM

Synopsis

REM «string»

Options

Unless stated otherwise all options of this command do follow the
standard rules for options.

Examples

Example: 1


REN - Rename files

See also: RENAME
Requirements: CMD_RENAME

Synopsis

REN source destination

Options

Unless stated otherwise all options of this command do follow the standard rules for options.

Examples

Example: 1


RENAME - Rename files

This command is 100% compatible to REN, please see there


RMDIR - Remove directory

This command is 100% compatible to RD, please see there


SET - Display or set environment variables

Requirements: CMD_SET

Synopsis

SET
SET variable '=' «string»

Options

Unless stated otherwise all options of this command do follow the
standard rules for options.

Examples

Example: 1


SHIFT - Shift the arguments of a batch script

Requirements: CMD_SHIFT

Synopsis

  1. SHIFT
  2. SHIFT DOWN

Shifts the arguments of a batch script one position up (first variant) or down (second variant).

Within a batch script the automatic variables %0 through %9 are replaced by the script name and the first nine arguments. This can be imagined as a window to ten arguments of the script. SHIFT will allow to move this window of ten arguments towards its end (up) or its start (down).

After SHIFT has been executed, the former %0 is hidden and inaccessable, %1 became %0, %2 became %1 a.s.o, %9 became %8 and the formerly hidden tenth argument became %9.
SHIFT DOWN reverses one SHIFT command.

SHIFT can be called as many times as wanted, SHIFT DOWN won't allow to underflow the very first argument.

Examples

Example: 1

If the batch script B.BAT:
@ECHO OFF
ECHO 0: %0
ECHO 1: %1
ECHO 2: %2
had been executed using:
B.BAT 1 2 3 4
it displays:
B.BAT
1
2

If a SHIFT command had been inserted as second line, the same call displays:
1
2
3


TIME - Display or set current time

See also: DATE
Requirements: CMD_TIME

Synopsis

  1. TIME [ /T ]
  2. TIME [ /T ] time
Variant 1 displays the current time, then enters a loop prompting the user to enter a new time. The loops terminates when a valid time had entered or the user just pressed the ENTER key.

Variant 2 does not display the current time, but tries to change the current time to the specified time, on failure the loop as explained above is entered.

The individual portions of a time may be sperated by at least: dots ., colons : and forward slashes /. Other nationally used characters may be supported, too. If a certain number of portions are specified:

  1. error,
  2. hour:minute; seconds and hundreds default to zero,
  3. hour:minute:seconds; hundreds defaults to zero,
  4. hour:minute:seconds.hundreds;
  5. more than 4 portions result in an error.
Separated by no, one or more whitespaces the am/pm modifiers may follow optionally. If present they alter the given time as follows:
  • AM: if hour is equal to 12, it becomes 0 (midnight).
  • PM: f hour is greater than 12, it is incremented by 12.

Options

All options must preceed any arguments.

/T: prevents from prompting the user.

  1. In variant 1, the time is displayed only.
  2. In variant 2, the time is tried to be changed, but the loop is not entered on failure.

Examples

Example: 1

TIME /T
Just displays the current time.

Example: 2

TIME 18:2
Sets the current system time to 6:02 PM.


TRUENAME - Display the true name of a file

Requirements: CMD_TRUENAME

Synopsis

TRUENAME path

Options

Unless stated otherwise all options of this command do follow the
standard rules for options.

Examples

Example: 1


TYPE - Display the contents of files

See also: DIR, ECHO
Requirements: CMD_TYPE

Synopsis

TYPE { pattern }

Options

Unless stated otherwise all options of this command do follow the standard rules for options.

Examples

Example: 1


VER - Display the version information about FreeCOM and DOS

Requirements: CMD_VER

Synopsis

VER [{ option }]

Options

Unless stated otherwise all options of this command do follow the
standard rules for options.

Examples

Example: 1


VERIFY - Display or set verify level

Requirements: CMD_VERIFY

Synopsis

VERIFY [ ON | OFF ]

Options

Unless stated otherwise all options of this command do follow the
standard rules for options.

Examples

Example: 1


VOL - Display the volume label of a drive

See also: DIR

Synopsis

VOL [ drive ]

Options

Unless stated otherwise all options of this command do follow the standard rules for options.

Examples

Example: 1


WHICH - Search and display the executable file of specified commands

Requirements: CMD_WHICH

Synopsis

WHICH [{ command }]

Searches for the specified command(s) the same way as if it would be specified on command line as command itself. If an executable file is found, its path is displayed in this format:
command «tab» path

The «tab» stands for the tabulator character (ASCII 9).
If the command is not found only the command part, but neither a path nor the «tab» is displayed.

Internal commands, installable commands and aliases are not found.

Examples

Example: 1

WHICH which
Returns a file or nothing, because WHICH is an internal command.

Example: 2

WHICH command
Could display for instance:
command	C:\COMMAND.COM

Please note that command is the string "command" and no placeholder.


Appendix

Current Directory

The current directory is the default directory of a drive.

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.

Current Working Direcory

In opposite to the current directory the current working directory is the absolute path constructed out of the currently selected drive and current directory of that drive.

Path Specification

In DOS an absolute path is constructed out of several components:
  1. drive,
  2. directory,
  3. filename, and
  4. file extension.
like this: D:\DIR1\DIR2\FILENAME.EXT.

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:

  • If no drive is specified, what means that no colon is specified, the path is prefixed by the currently selected drive.
  • If the directory is not prefixed by the backslash or no directory is specified at all, the current directory of the drive is inserted right behind the colon.
  • Some programs may append an absent extension to the very last filename component.

Examples, assume the current directories of
Drive Current Directory
C: \FREEDOS\HELP
D: \TEMP\TEXT
The currently selected drive is C:.

  1. C:\
    The root directory of drive C:.
  2. .
    The current working directory, ergo: C:\FREEDOS\HELP.
  3. ..
    The parent directory, ergo: C:\FREEDOS.
  4. D:
    The current directory of drive D:, ergo: D:\TEMP.
  5. D:.
    The current directory of drive D:, ergo: D:\TEMP.
  6. D:..
    The parent directory of drive D:, ergo: D:\.
  7. ..\BIN
    Because there is neither a drive nor a leading backslash, both the currently selected drive and the current directory of that drive is inserted before the given path, ergo: C:\FREEDOS\HELP\..\BIN.
    The embedded component .. has the same meaning as when specified alone: parent directory, though, here in the context of the directory C:\FREEDOS\HELP\. That means that the final absolute path is: C:\FREEDOS\BIN.

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:

  • multiple backslashes,
  • multiple dots,
  • multiple colons, or a colon at a position unequal to two,
  • The current directory . or parent directory .. special directories in the context of a root directory, such as C:\., C:\.., or C:\TEMP\..\...

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.

Standard Rules for Options

Options are prefixed by one forward slash "/", the following character identifies the option and is called option character, for instance: /A

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 or without embedded slashes, e.g. /WS or /W/S, instead of /W /S.
However, because some commands do accept long option names, the way with embedded slashes is more secure and is recommended therefore.
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 optionally prefixed by a plus "+" or minus "-" sign. So, the boolean option O can be written in three ways:

  1. /+O: The option is enabled.
  2. /-O: The option is disabled.
  3. /O: (neither plus nor minus sign) The option is toggled or flipped; this means if the option is enabled currently, it is disabled; but if it is disabled currently, it is enabled.

Without user invention a boolean option is disabled by default, so both /+O and /O behave the same most of the time. However, some commands allow the user to change the default settings of certain options, e.g. COPY and DIR.

I/O Redirection

In DOS the standard input and output can be redirected to a file or another device; however, although it is common to use these I/O streams today, some programmers cowardly ignore them for reasons of speed or program size.

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
>& Output and error stream; target file is overwritten
>>& Output and error stream; output is appended to target, if it already exists
>&> Error stream; target file is overwritten
>>&> Error stream; output is appended to target, if it already exists

Examples

Example: 1

cmd <in1 <in2

Input stream is redirected to file IN2, because it is the rightmost one.

Example: 2

cmd <in >&out

Input stream is redirected to file IN, output and error streams are joined together and redireced into file OUT. If the file OUT already exists, the old contents is discarded and replaced by the new one; otherwise, the OUT is created anew.

Example: 3

cmd <in >>&out

As example 2, but instead of replacing the contents of OUT, if the file already exists, the new information is appended to the end of the file.

Example: 4

FOR %a IN (*.*) DO ECHO %a >out

As mentioned earlier, FOR is an exception and passes forth the redirections to each invocation of the command specified right of the DO keyword. So this examples overwrites the output file each time the ECHO command is performed, thus, instead of creating a file list, only the last found file is recorded into OUT.

Example: 5

IF EXIST out DEL out
FOR %a IN (*.*) DO ECHO %a >>out

This sequence eliminate the problem, the IF command is required to actually replace the file rather than appending the file list to the probably existent file.

Pipes

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.

Examples

Example: 1

cmd1 | cmd2 | cmd3

Which is similiar to this sequence:
cmd1 >%TEMP%\t1
cmd2 <%TEMP%\t1 >%TEMP%\t2
DEL %TEMP%\t1
cmd3 <%TEMP%\t2
DEL %TEMP%\t2

Example: 2

The first and last command can have an input or output redirection respectively, like so:
cmd1 | cmd2 | cmd3 <in >out

Which is similiar to this sequence:
cmd1 >%TEMP%\t1 <in
cmd2 <%TEMP%\t1 >%TEMP%\t2
DEL %TEMP%\t1
cmd3 <%TEMP%\t2 >out
DEL %TEMP%\t2

Example: 3

The error stream can be piped as well:
cmd1 |& cmd2 | cmd3

Which is similiar to this sequence:
cmd1 >&%TEMP%\t1
cmd2 <%TEMP%\t1 >%TEMP%\t2
DEL %TEMP%\t1
cmd3 <%TEMP%\t2
DEL %TEMP%\t2

Here only the error messages of cmd1 are passed into cmd2; the error messages of both cmd2 and cmd3 are issued to the screen.

Nested redirections

Batch scripts or when external programs invoke other programs or another shell, redirections may be nested, e.g.:

Consider the batch file BATCH.BAT:

@ECHO OFF
ECHO 1
ECHO 2 >out_2
ECHO 3
which is invoked via:
BATCH >out_1

When the script BATCH gets executed, the actual output stream is redirected to the file OUT_1. Therefore the output of the first ECHO command is redirected into this file.
Because the second ECHO command has its own output redirection, its output is redirected into the file OUT_2. On completion of ECHO the redirection is closed and the former one is restored.
What causes that the output of the third ECHO command is redirected into OUT_1 again.