Batch Builtin Commands

The set of portable commands.


Commands

Commands

Description

Example

assoc

break

No-op; legacy from MS-DOS

call

cd

Alias of chdir

chdir

Changes working directory; if no argument supplied, prints the current working directory

cls

Clears the screen

color

Sets the background and foreground colors

copy

Copies one or more files; if the destination is not provided, the current working directory is used

del

Deletes one or more files

dir

Lists the contents of a directory

date

Outputs the system date

echo

Writes a message

endlocal

Ends local scoping of environment variables

erase

Alias of del

exit

Immediately exits the current shell

ftype

goto

md

Alias of mkdir

mkdir

Creates a directory

mklink

Creates a symbolic link

move

Moves one or more files; if the destination is not provided, the current working directory is used

path

Outputs or sets the value of %PATH%

pause

Prompts the user for input before continuing

popd

prompt

pushd

rd

Alias of rmdir

ren

Alias of rename

rename

Renames one or more files

rem

rmdir

Delete one or more directories

set

Outputs or sets environment variables

setlocal

Causes all subsequent changes to environment variables to be locally scoped

shift

Renames the positional variables; %2 becomes %1, etc.

start

time

Outputs the system date

title

type

ver

Prints the operating system version

verify

vol

Lists volume names

Copy and Rename

copy and rename can take wildcard patterns to bulk rename files.

copy *.txt *.bak

Echo

To disable echoing, try:

@echo off

Set

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


Color Codes

Valid colors background and foreground 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


Reserved Keywords

Some parts of the language are technically implemented as a command.

See here for if and else.

See here for for.


CategoryRicottone