Académique Documents
Professionnel Documents
Culture Documents
Examples .................................................................................................................................................................15
Microsoft DOS move command .............................................................................................................................16
About move .............................................................................................................................................................16
Availability...............................................................................................................................................................16
Syntax ......................................................................................................................................................................16
Examples .............................................................................................................................................................17
Microsoft DOS copy command...............................................................................................................................17
About copy ..............................................................................................................................................................18
Availability...............................................................................................................................................................18
Windows Vista and later syntax ........................................................................................................................18
Windows XP and earlier syntax .........................................................................................................................19
Examples.................................................................................................................................................................20
Microsoft DOS xcopy command ......................................................................................................................................21
About xcopy ................................................................................................................................................................21
Availability ..................................................................................................................................................................21
Syntax .........................................................................................................................................................................21
Windows 98 and older syntax .....................................................................................................................................24
Examples.................................................................................................................................................................25
Questions and answers ...............................................................................................................................................26
Microsoft DOS robocopy command ................................................................................................................................27
About robocopy ..........................................................................................................................................................27
Availability ..................................................................................................................................................................27
Syntax .........................................................................................................................................................................27
Copy options ...............................................................................................................................................................27
File Selection Options ..................................................................................................................................................30
Retry Options ..............................................................................................................................................................31
Logging Options ..........................................................................................................................................................31
Examples.................................................................................................................................................................33
Microsoft DOS edit command ................................................................................................................................34
About edit ................................................................................................................................................................34
Availability...............................................................................................................................................................35
Syntax ......................................................................................................................................................................35
Examples .............................................................................................................................................................36
Using edit to create a file .....................................................................................................................................36
Additional information .........................................................................................................................................37
Availability
The cls command is an internal command and is available in the below Microsoft operating
systems.
Syntax
CLS
Examples
cls
Running the cls command at the command prompt would clear your screen of all previous
text and only return the prompt.
Availability
The mklink command is an internal command that is available in the below Microsoft
operating systems.
Syntax
MKLINK [[/D] | [/H] | [/J]] Link Target
/D
/H
/J
Link
Target
specifies the path (relative or absolute) that the new link refers to.
Examples
Note: the mklink command requires you to be in an elevated command prompt.
mklink /d \Docs \Users\Hope\Documents
The above example command would create a symbolic link called "Docs" to the
\Users\Hope\Documents directory, even if the directory does not exist. If created
successfully you will see a message similar to the example shown below.
symbolic link created for \Docs <<===>> \Users\Hope\Documents
Once the Symbolic link has been created using the dir command you can see any
symbolic link in the directory listing of where the symbolic link was created. Below is an
example of what the above symbolic link directory <SYMLINKD> would look like in the
command line.
To get into the symbolic link directory you would treat it like any other directory and use
the cd command. To get into the Docs directory you would type "cd docs" at the prompt.
Availability
The CD command is an internal command and is available in the below Microsoft operating
systems.
Syntax
Windows XP and later syntax
CHDIR [/D] [drive:][path]
CHDIR [..]
CD [/D] [drive:][path]
CD [..]
.. Specifies that you want to change to the parent directory.
Type CD drive: to display the current directory in the specified drive.
Type CD without parameters to display the current drive and directory.
Use the /D switch to change current drive in addition to changing current directory for a
drive.
CHDIR command does not treat spaces as delimiters, to CD into a subdirectory name that
contains a space without surrounding the name with quotes. For example:
chdir \winnt\profiles\username\programs\start menu
Examples
cd\
Goes to the highest level, the root of the drive.
cd..
Goes back one directory. For example, if you are within the C:\Windows\COMMAND>
directory, this would take you to C:\Windows>
Windows 95, 98, and later versions have a feature in the CD command that allows you to
go back more than one directory when using the dots. For example, typing: cd... with
three dots after the cd would take you back two directories.
cd windows
If present, would take you into the Windows directory. Windows can be substituted with
any other name.
cd\windows
If present, would first move back to the root of the drive and then go into the Windows
directory.
cd\windows\system32
If present, would move into the system32 directory located in the Windows directory. If at
any time you need to see what directories are available in the directory you're currently in
use the dir command.
cd /d e:\pics
If for example you were on the C: drive, typing the above command with the /d option
would first switch the E: drive letter and then move into the pics directory.
cd
Typing cd alone will print the working directory. For example, if you're in c:\windows> and
you type the cd it will print c:\windows. For those users who are familiar with Unix or
Linux this could be thought of as doing the pwd (print working directory) command.
Availability
The dir command is an internal command and is available in the below Microsoft operating
systems.
Syntax
Microsoft Windows 2000, XP, Vista, 7, and 8 syntax
Displays a list of files and subdirectories in a directory.
DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] [/O[[:]sortorder]] [/P]
[/Q] [/R] [/S] [/T[[:]timefield]] [/W] [/X] [/4]
[drive:][path][filename]
/A
attributes
D Directories
R Read-only files
H Hidden files
S System files
L Reparse Points
/B
/C
/D
/L
Uses lowercase.
/N
New long list format where filenames are on the far right.
/O
sortorder
/P
/Q
/R
/S
/T
timefield
C Creation
A Last Access
W Last Written
/W
/X
/4
/P
/W
/A
attributes:
D Directories
R Read-only files
H Hidden files
A Files ready for archiving
S System files
- Prefix meaning not
/O
/S
/B
/L
Uses lowercase.
/V
Verbose mode.
Switches may be preset in the DIRCMD environment variable. Override preset switches by
prefixing any switch with - (hyphen)--for example, /-W.
Examples
dir
Lists all files and directories in the directory that you are currently in. By default the dir
command will list the files and directories in alphabetic order.
dir *.exe
The above command lists any file that ends with the .exe file extension. See the wildcard
definition for further wildcard examples.
dir *.txt *.doc
The above is using multiple filespecs to list any files ending with .txt and .doc in one
command.
dir /ad
List only the directories in the current directory. If you need to move into one of the
directories listed use the cd command.
dir /s
Lists the files in the directory that you are in and all sub directories after that directory, if
you are at root "C:\>" and type this command this will list to you every file and directory on
the C: drive of the computer.
dir /p
If the directory has lots of files and you cannot read all the files as they scroll by, you can
use this command and it displays all files one page at a time.
dir /w
If you don't need the info on the date or time and other information on the files, you can
use this command to list just the files and directories going horizontally, taking as little as
space needed.
dir /s /w /p
This would list all the files and directories in the current directory and the sub directories
after that, in wide format and one page at a time.
dir /on
List the files in reverse alphabetical order by the names of the files.
dir \ /s |find "i" |more
A nice command to list all directories on the hard drive, one screen page at a time, and see
the number of files in each directory and the amount of space each occupies.
dir > myfile.txt
Takes the output of dir and re-routes it to the file myfile.txt instead of outputting it to the
screen.
The above example creates the "test" directory in the current directory.
mkdir "computer hope"
The above command would create a directory called "computer hope", if you want a space
in your directory name it must be surrounded in quotes.
md c:\test
Availability
The rd and rmdir commands are internal commands and are available in the below
Microsoft operating systems.
Syntax
Windows XP and later syntax
Windows 95, 98, and ME syntax
Windows XP and later syntax
RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path
/S
Removes all directories and files in the specified directory in addition to the
directory itself. Used to remove a directory tree.
/Q
Examples
rmdir c:\full
If a directory contains files or folders when attempting to delete the directory you will
receive "The directory is not empty." error message. If you want to delete directories that are
full, use the deltree command or if you're using Windows 2000 or later use the example
below with the /s switch.
rmdir c:\test
Windows 2000, Windows XP and later versions of Windows can use this option with a
prompt to permanently delete the test directory and all subdirectories and files. Adding the
/q switch would suppress the prompt.
Specifies the location and name of the file or files you want to
move.
destination
[drive:][path]dirname1
dirname2
/Y
/-Y
The switch /Y may be present in the COPYCMD environment variable. This may be
overridden with /-Y on the command line. Default is to prompt on overwrites unless MOVE
command is being executed from within a batch script.
Examples
Move the files of c:\windows\temp to the temp directory in root, this is of course assuming
you have the windows\temp directory. In this example, *.* is wildcards telling the computer
every file with every extension.
move "computer hope" example
If your directory name has a space, it must be surrounded with quotes, otherwise you will
get a "The syntax of the command is incorrect." error message. In the above example, this
command would move the "computer hope" directory into the example directory contained
in the same directory.
move stats.doc, morestats.doc c:\statistics
The above example would move the files stats.doc and morestats.doc into the c:\statistics
folder.
About copy
Allows the user to copy one or more files to an alternate location.
Availability
The copy command is an internal command and is available in the below Microsoft
operating systems.
/A
/B
/D
destination
/V
/N
/Y
/-Y
/Z
/L
If the source is a symbolic link, copy the link to the target instead of the
actual file the source link points to.
The switch /Y may be preset in the COPYCMD environment variable. This may be
overridden with /-Y on the command line. Default is to prompt on overwrites unless COPY
command is being executed from within a batch script.
To append files, specify a single file for destination, but multiple files for source (using
wildcards or file1+file2+file3 format).
/A
/B
destination
/V
/Y
/-Y
The switch /Y may be preset in the COPYCMD environment variable. This may be
overridden with /-Y on the command line.
To append files, specify a single file for destination, but multiple files for source (using
wildcards or file1+file2+file3 format).
Examples
In the above copy command we are using a wildcard to copy all .txt files (multiple files) from
the current directory to the c:\ root directory.
copy *.* a:
Copy all files in the current directory to the floppy disk drive.
Note: If there are hidden files they will not be copied. To copy all files including hidden files
use the xcopy command.
copy autoexec.bat c:\windows
Copy the autoexec.bat, usually found at root, and copy it into the windows directory; the
autoexec.bat can be substituted for any file(s).
copy win.ini c:\windows /y
Copy the win.ini file in the current directory to the windows directory. Because this file
already exists in the windows directory it normally would prompt if you want to overwrite
the file. However, with the /y switch you will not receive any prompt.
copy "computer hope.txt" hope
Copy the file "computer hope.txt" into the hope directory. Whenever dealing with a file or
directory with a space, it must be surrounded with quotes. Otherwise you'll get the "The
syntax of the command is incorrect." error.
copy myfile1.txt+myfile2.txt
Copy the contents in myfile2.txt and combines it with the contents in myfile1.txt.
Finally, a user can create a file using the copy con command as shown above, which
creates the test.txt file. Once the above command has been typed in, a user could type in
whatever he or she wishes. When you have completed creating the file, you can save and
exit the file by pressing CTRL+Z, which would create ^Z, and then press enter. An easier
way to view and edit files in MS-DOS would be to use the edit command.
Availability
The xcopy command is an external command that is available in the below Microsoft
operating systems
Syntax
Windows 2000, XP, and later syntax
Windows 98 and older syntax
Windows 2000, XP, and later syntax
XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W] [/C] [/I] [/Q] [/F]
[/L] [/H] [/R] [/T] [/U] [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/B] [/J]
[/EXCLUDE:file1[+file2][+file3]...]
Note: Only Windows Vista and later includes the [/B] and [/J] options.
source
destination
/A
Copies only files with the archive attribute set, doesn't change the
attribute.
/M
Copies only files with the archive attribute set, turns off the archive
attribute.
/D:m-d-y
/EXCLUDE:file1
[+file2][+file3]...
/P
/S
/E
/V
/W
/C
/I
If destination does not exist and copying more than one file, assumes
that destination must be a directory.
/Q
/F
/L
/H
/R
/T
Creates directory structure, but does not copy files. Does not include
empty directories or subdirectories. /T /E includes empty directories
and subdirectories.
/U
/K
/N
/O
/X
/Y
/-Y
/Z
/B
Copies the Symbolic Link itself versus the target of the link.
/J
destination
/A
Copies files with the archive attribute set, doesn't change the attribute.
/M
Copies files with the archive attribute set, turns off the archive attribute.
/D:date
/P
/S
/E
/W
/C
/I
If destination does not exist and copying more than one file, assumes
/F
/L
/H
/R
/T
Creates directory structure, but does not copy files. Does not include
empty directories or sub directories. /T /E includes empty directories
and sub directories.
/U
/K
/Y
/-Y
/N
Examples
In the above example, the xcopy command will copy all files in the current directory
including any hidden files into the hope directory.
xcopy c:\temp /e
The above example is the basic xcopy command to copy the files, directories, and
subdirectories to the directory you're currently in.
xcopy "c:\documents and settings\hope" /e
In the above example the xcopy command would copy all files and directories in the user
"hope" directory to the directory or drive you're currently in.
xcopy hope example /e
In the above example this xcopy command copies all directories (even empty directories)
and files from the hope directory into the example directory.
xcopy h:\*.* /a /e /k
The above command would copy everything located on the H drive to the drive you are
currently on.
Parse error
This error occurs when the command you're typing in has invalid syntax. For example, if
you're surrounding your path in quotes and leave out the ending quotes.
I attempted to use the above xcopy command and was not able to copy all files within
my favorites folder.
After further examination, Computer Hope also encountered this issue. However, was able
to copy the majority of all favorites by using the below command.
xcopy c:\windows\favorites\*.* /e /k /i /c
We are under the impression that this issue is generated because of the way that Internet
Explorer saves the URL (favorite) using long file names as well as extended characters.
Availability
The robocopy.exe command is an external command that is available in the below Microsoft
operating systems.
Syntax
ROBOCOPY source destination [file [file]...] [options]
source
destination
file
Copy options
/S
/E
/LEV:n
/Z
/B
/ZB
/EFSRAW
/COPY:copyflag[s]
/DCOPY:T
/SEC
/COPYALL
/NOCOPY
/SECFIX
/TIMFIX
/PURGE
/MIR
/MOV
/MOVE
/A+:[RASHCNET]
/A-:[RASHCNET]
/CREATE
/FAT
/256
/MON:n
/MOT:m
/RH:hhmmhhmm
/PF
/IPG:n
/SL
/MT[:n]
/M
Copy only files with the Archive attribute and reset it.
/IA:[RASHCNETO]
/XA:[RASHCNETO]
/XC
/XN
/XO
/XX
/XL
/IS
/IT
/MAX:n
/MIN:n
/MAXAGE:n
/MINAGE:n
/MAXLAD:n
/MINLAD:n
/XJ
/FFT
/DST
/XJD
/XJF
Retry Options
/R:n
/W:n
/REG
/TBD
Logging Options
/L
/X
/V
/TS
/FP
/BYTES
/NS
/NC
/NFL
/NDL
/NP
/ETA
/LOG:file
/LOG+:file
/UNILOG:file
/UNILOG+:file
/TEE
/NJH
No Job Header.
/NJS
No Job Summary.
/UNICODE
Job Options
/JOB:jobname
/SAVE:jobname
/QUIT
/NOSD
/NODD
/IF
Examples
In this first example any .txt file would be copied from the hope directory into the hope2
directory. Whenever you want to copy one or more files and not a complete directory the file
must be specified after the destination directory.
robocopy c:\hope c:\hope2
In the above example the robocopy command would copy all files (not directories) in the
hope directory to the hope2 directory.
In the above example all files and folders (including empty ones) will be copied from the
hope directory to the hope2 directory.
robocopy c:\hope c:\hope2 /MIR
This example will mirror what is in c:\hope into c:\hope2 and purge any files in the hope2
directory that do not exist in the hope directory. Use the /mir switch cautiously since it will
be deleting files that do not match in the destination directory.
robocopy \\computer\hope C:\hope2
Next, this example would copy any of the files in the hope directory on the network
computer named computer to the current computer hope2 directory.
Availability
The edit command is an external command that is available in the below Microsoft
operating systems.
MS-DOS 5.x and above
Windows 95
Windows 98
Windows ME
Windows NT
Windows 2000
Windows XP
Windows Vista*
Windows 7*
* 64-bit versions of Windows do not support the edit command use notepad to edit files.
Notepad can be started from the Windows command line by using the start command.
Syntax
EDIT [/B] [/H] [/R] [/S] [/<nnn>] [/?] [file(s)]
/B
/H
/R
/S
/<nnn>
/?
[file]
Specifies initial files(s) to load. Wildcards and multiple file specs can be
given.
Examples
edit c:\autoexec.bat
This would look at the autoexec.bat. However, if the file is not found a blank blue screen is
shown. When editing this or any file, ensure that you know what you are placing in the files
improperly editing the file can cause issues with your computer.
If you are unable to get this program to work, try typing in "path c:\windows\command" if
you haveWindows 95 or higher, or type in "path c:\dos" if you have Dos 5.x/6.x/7.x
or Windows 3.x and try again. If you still are not able to get edit to work, it may not be on
the hard drive; Type in dir edit.com /s at the c:\>. If it says that the file is not found, you
may not have this feature.
If you are running an MS-DOS version 4.x or lower or you are unable to find edit.com on
your hard drive, you can also use the below command to create a file.
copy con <name of file>
Once you have entered the above command this will create the file with the name specified.
Once you have typed all the lines you want to be in the file, press and hold CTRL + Z. This
should enter ^Z, once on the screen, press enter and one file should be copied.
edit myfile.txt
This would bring up a blank edit screen, as long as the file is saved upon exit this will
create the file myfile.txt.
Additional information
Note: Edit is only able to open a file with a maximum of 65,280 lines.
If your mouse drivers are not loaded while in MS-DOS or the Windows command line you
may have no mouse support. It is still possible to navigate the Editor using shortcut keys
as seen in the below list.
Quick Tip: Pressing Alt allows you to quickly navigate through edit without having to
memorize the below commands.
Home
End
Ctrl + Up
Ctrl + Down
PageUp
PageDown
Ctrl + PageUp
Ctrl + PageDown
Ctrl + Home
Ctrl + End
Ctrl + Left
Ctrl + Right
Enter
Delete (Del)
Backspace
Tab
Insert
Ctrl + Y
Ctrl + V
Ctrl + P
Shift
Ctrl + C
Ctrl + X
Shift + Tab
Ctrl + Q + F
Find text.
Ctrl + Q + A
F3
F6
Ctrl + F6
Ctrl + F4
Ctrl + F8
F1
Displays help.
Availability
The del command is an internal command and is available in the below Microsoft operating
systems.
The delete command is a recovery console command and is available in the below Microsoft
operating systems.
Windows 2000
Windows XP
Syntax
Windows XP, Windows 2000, and later syntax
Windows 2000 and Windows XP recovery console syntax
Windows 95, 98, and ME syntax
Windows XP, Windows 2000, and later syntax
Deletes one or more files.
/P
/F
/S
/Q
/A
attributes
R Read-only files S System files H Hidden files A Files ready for archiving Prefix meaning not
/P
Examples
Note: In Microsoft Windows deleted items go to the Recycle Bin, keep in mind that deleting
files from MS-DOS or the Windows command line does not send files to the Recycle Bin.
Tip: Use the rmdir or deltree command to delete directories
del test.tmp
The * (asterisks) is a wild character, *.* indicates that you would like to delete all files in the
c:\windows\temp directory.
del c:\windows\temp\?est.tmp
The ? (question mark) is a single wild character for one letter, which means this command
would delete any file ending with est.tmp such as pest.tmp or zest.tmp.
Availability
The attrib.exe command is an external command that is available in the below Microsoft
operating systems.
MS-DOS 3.0 and above
Windows 95
Windows 98
Windows ME
Windows NT
Windows 2000
Windows XP
Windows Vista
Windows 7
Windows 8
Syntax
Windows 7 and Windows 8 syntax
Microsoft Windows 2000 and Windows XP syntax
Microsoft Windows 2000 and Windows XP recovery console syntax
Microsoft Windows 95, 98, and ME syntax
Windows 7 and Windows 8 syntax
Displays or changes file attributes.
ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [+I | -I] [drive:][path][filename] [/S [/D] [/L]]
+
Sets an attribute.
Clears an attribute.
Integrity attribute.
/S
/D
/L
Work on the attributes of the Symbolic Link versus the target of the
Symbolic Link
See our attrib examples for information and examples on how to use this command.
Microsoft Windows 2000 and Windows XP syntax
Displays or changes file attributes.
ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [[drive:] [path] filename] [/S [/D]]
+
Sets an attribute.
Clears an attribute.
/S
/D
See our attrib examples for information and examples on how to use this command.
Microsoft Windows 2000 and Windows XP recovery console syntax
Note: The below options are the available options in the Windows recovery console.
Changes attributes on one file or directory.
ATTRIB -R | +R | -S | +S | -H | +H | -C | +C filename
+
Sets an attribute.
Clears an attribute.
See our attrib examples for information and examples on how to use this command.
Sets an attribute.
Clears an attribute.
/S
Examples
attrib
Typing attrib by itself displays all files in the current directory and each of their attributes.
If any file is hidden it also displays those files.
As can be seen in the above example we typed the dir command to list the files in the
current directory and could only see the "computer.bat" file listed. However, when we type
attrib by itself, we can see that there are three files in this directory, "computer.bat" with
read-only, "example.txt" with hidden, and "hope.txt" with the hidden and read-only
attribute.
attrib +r autoexec.bat
Add the read-only attribute to the autoexec.bat file so it cannot be modified until the readonly attribute is taken off. This is helpful for important system files or any other file that
you do not want to have mistakenly edited or changed by another program.
attrib +h config.sys
Add the hidden attribute to the config.sys file causing it to be not be seen by the average
user.
attrib -h config.sys
This command does the opposite of the example shown before this command. Instead of
hiding the file this command makes the file visible if hidden.
attrib +r +h autoexec.bat
Finally, this example adds two attributes to the autoexec.bat and makes the file read-only
as well as hidden.
How can I see hidden files in MS-DOS?
Extended information
Most users never need to deal with a files bit position or hex value. However, for those
needing this information when working with MS-DOS and the Windows command line
below are the file attributes bit positions and HexValues with bit positions in the order of "7
6 5 4 3 2 1 0."
Bit Positions
Hex
0000000
1
01h
Read-only file
0000001
0
02h
Hidden file
0000010
0
04h
System file
0000100
0
08h
Volume Label
0001000
0
10h
Subdirectory
0010000
0
20h
Archive
0100000
0
40h
Reserved
1000000
0
80h
Reserved
Examples
Description
0010000
1
21h
Read-only, Archive
0011001
0
32h
0010011
1
27h
0010001
1
23h
Additional information