Batch Builtin Commands
Contents
Assoc
Break
Does nothing. Was used in MS-DOS.
Call
Cd
A synonym of CHDIR.
ChDir
Changes the working directory. If a new directory is not named, prints the current working directory.
Cls
Clears the screen.
Color
Sets the background and foreground colors.
Valid colors are:
Code |
Color |
0 |
Black |
1 |
Navy |
2 |
Green |
3 |
Teal |
4 |
Maroon |
5 |
Purple |
6 |
Olive |
7 |
Silver |
8 |
Gray |
9 |
Blue |
A |
Lime |
B |
Aqua |
C |
Red |
D |
Fuchsia |
E |
Yellow |
F |
White |
To set the background color to green and the foreground color to yellow, try:
color 2e
Copy
Copies one or more files.
If a filename contains spaces, quote it.
If a destination is not specified, the current working directory is used.
copy C:\foo
If wildcard patterns are used in both the source and destination, files are copied into renamed files.
copy *.txt *.bak
Del
Deletes one or more files.
Dir
Lists the contents of a directory.
Date
Outputs the system date.
Echo
Writes a message.
To disable echoing, try:
@echo off
Else
See here.
EndLocal
Ends local scoping of environment variables.
Erase
Synonym of DEL.
Exit
Immediately exits the current shell.
For
See here.
FType
GoTo
If
See here.
Md
Synonym of MKDIR.
MkDir
Creates a directory.
MkLink
Creates a symbolic link.
Move
Moves one or more files.
If a filename contains spaces, quote it.
If a destination is not specified, the current working directory is used.
copy C:\foo
Path
Outputs or sets the value of %PATH%.
Pause
Prompts the user for input before continuing.
PopD
Prompt
PushD
Rd
Synonym for RMDIR.
Ren
Synonym of RENAME.
Rename
Renames one or more files.
Wildcard patterns can be used to indicate replacement.
rename *.txt *.bak
Rem
RmDir
Delete one or more directories.
If a filename contains spaces, quote it.
Set
Outputs or sets environment variables.
to prompt a user for a value, try:
set /p x=type a number:
To perform basic arithmetic, try:
set /a y=%x% + 1
Valid arithmetic operators are:
Operator |
Meaning |
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
SetLocal
Causes all subsequent changes to environment variables to be locally scoped.
Shift
Renames the special positional variables. %2 is renamed to %1, %3 is renamed to %2, and so on.
Start
Time
Outputs the system date.
Title
Type
Ver
Prints the operating system version.
Verify
Vol
Lists volume names.