|
Size: 4099
Comment:
|
← Revision 4 as of 2025-12-19 19:44:00 ⇥
Size: 3856
Comment: Reorg
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 2: | Line 2: |
The set of portable commands. |
|
| Line 9: | Line 11: |
| == Assoc == | == Commands == |
| Line 11: | Line 13: |
| ---- | ||'''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|| || |
| Line 15: | Line 58: |
| == Break == | === Copy and Rename === |
| Line 17: | Line 60: |
| 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, [[Batch/Quoting|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` and `rename` can take wildcard patterns to bulk rename files. |
| Line 105: | Line 66: |
| ---- | |
| Line 108: | Line 68: |
== Del == Deletes one or more files. ---- == Dir == Lists the contents of a directory. ---- == Date == Outputs the system date. ---- == Echo == Writes a message. |
=== Echo === |
| Line 143: | Line 76: |
| ---- | |
| Line 146: | Line 78: |
| === Set === | |
| Line 147: | Line 80: |
| == Else == See [[Batch/Logic#If|here]]. ---- == EndLocal == Ends local scoping of environment variables. ---- == Erase == Synonym of `DEL`. ---- == Exit == Immediately exits the current shell. ---- == For == See [[Batch/Looping#For|here]]. ---- == FType == ---- == GoTo == ---- == If == See [[Batch/Logic#If|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, [[Batch/Quoting|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, [[Batch/Quoting|quote]] it. ---- == Set == Outputs or sets environment variables. to prompt a user for a value, try: |
To prompt a user for a value, try: |
| Line 355: | Line 104: |
| == SetLocal == | === Color Codes === |
| Line 357: | Line 106: |
| Causes all subsequent changes to environment variables to be locally scoped. | 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 || |
| Line 363: | Line 130: |
| == Shift == | == Reserved Keywords == |
| Line 365: | Line 132: |
| Renames the special positional variables. `%2` is renamed to `%1`, `%3` is renamed to `%2`, and so on. | Some parts of the language are technically implemented as a command. |
| Line 367: | Line 134: |
| ---- | See [[Batch/Logic#If|here]] for `if` and `else`. |
| Line 369: | Line 136: |
== Start == ---- == Time == Outputs the system date. ---- == Title == ---- == Type == ---- == Ver == Prints the operating system version. ---- == Verify == ---- == Vol == Lists volume names. |
See [[Batch/Looping#For|here]] for `for`. |
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.
