You are on page 1of 34

DOS commands are the commands available in MS-DOS that are used to interact with the operating system

and
other command line based software. Unlike in Windows, DOS commands are the primary way in which you use the operating
system.
List of DOS commands

In DOS, many standard system commands were provided for common tasks such as listing files on a disk or moving files. Some
commands were built into the command interpreter, others existed as external commands on disk. Over the several generations
of DOS, commands were added for the additional functions of the operating system. In the current Microsoft Windows operating
system, a text-mode command prompt window, cmd.exe, can still be used.

Command processing
The command interpreter for DOS runs when no application programs are running. When an application exits, if the transient
portion of the command interpreter in memory was overwritten, DOS will reload it from disk. Some commands are internal —
built into COMMAND.COM; others are external commands stored on disk. When the user types a line of text at the operating
system command prompt, COMMAND.COM will parse the line and attempt to match a command name to a built-in command or to
the name of an executable program file or batch file on disk. If no match is found, an error message is printed, and the command
prompt is refreshed.
External commands were too large to keep in the command processor, or were less frequently used. Such utility programs would
be stored on disk and loaded just like regular application programs but were distributed with the operating system. Copies of
these utility command programs had to be on an accessible disk, either on the current drive or on the command path set in the
command interpreter.
In the list below, commands that can accept more than one file name, or a filename including wildcards (* and ?), are said to
accept a filespec (file specification) parameter. Commands that can accept only a single file name are said to accept
a filename parameter. Additionally, command line switches, or other parameter strings, can be supplied on the command line.
Spaces and symbols such as a "/" or a "-" may be used to allow the command processor to parse the command line into
filenames, file specifications, and other options.
The command interpreter preserves the case of whatever parameters are passed to commands, but the command names
themselves and file names are case-insensitive.
Many commands are the same across many DOS systems, but some differ in command syntax or name.

Microsoft Disk Operating System is full form of MS DOS. It is system software. MS-DOS is a single user operating
system. MS-DOS support CUI (Character User Interface). At first operating system is Microsoft Disk Operating System
from first introduce computer. Here we are going to discuss the MS-DOS commands. MS-DOS is machine language that
links between application software and hardware and control all activities. The activities are-

 NS DOS control by the commands.


 MS-DOS is a single user single task operating system.
 MS-DOS have some utility and necessary to use.
 Only Keyboard used in MS-DOS.
 MS-DOS support CUI.

Types of Files in MS-DOS Commands :

Two types of MS-DOS files-

1. System File: These files are controlled to Booting of MS-DOS. Normally three types of files are maintained in
DOS. These are- IO.SYS, MSDOS.SYS & COMMAND.COM. The main file of DOS is COMMAND.COM.
2. Start-up File: The Booting time the Start-up File commands are normally run.MS-DOS COMMANDS:

MS-DOS commands are used to the function of file and disk activities. There are two types of MS-DOS commands.

1. Internal Command: Internal Command is work by Command.Com file. The features of Internal Command is-
 The working speed of this command is very fast.
 This command is used much time.
 Do not erase Internal Command.
 The length of Internal Command is very short.

The example of Internal Command is: –


DATE, TIME, VOL, VER, CLS,COPY CON, DIR, MD, DEL, REN, TYPE, PROMPT, PAUSE etc.

2. External Command: Some commands are used in external part that is known as External Command. The
features of External Command is-

 The length of External Command is very long.


 Erased this commands.
 Working speed is very slow.

The example of External Command is: –

ATTRIB, SORT, EDIT, TREE, MOVE, DISKCOPY, FIND, XCOPY, MORE, LABLE, FORMATE etc.

How to Start MS-DOS?


How to Change Drive?

Internal Commands of MS-DOS

 DATE– It is an Internal Command. By this Command we can see and modify the current date on the computer
system.

 TIME – It is an Internal Command. By this we can see and display the current time on the computer system.

 VOL (Volume) – It is an Internal Command. By this command, we can see the Volume number of system
software.
 VER (Version) – It is an Internal Command. By this command, we can see the version number of system
software.

 CLS – It is an Internal Command. This command is used to clear the screen.


 COPY CON: – It is an Internal Command. By this command we can create a new file.

 DIR: – It is an Internal Command. By this command we can display the files and directories name list.

 DIR/P: – It is an Internal Command. By this command we can display page wise files name.
 DIR/W: – It is an Internal Command. By this command we can display width wise all files and directories
name list without time, size etc.

 DIR/B: – It is an Internal Command. By this command we can display only primary name list of files and
directories.

 DIR/L: – It is an Internal Command. By this command we can display the file and directories name with lower
case.
 DIR/S: – It is an Internal Command. By this command we can display directories name with sub directories
and files.

 DIR/AH: – It is an Internal Command. By this command we can display the hidden file from the drive.

 DIR A*.* :- It is an Internal Command. By this command we can display all file names begging the ‘A’ letter.

• DIR *.TXT: –
It is an Internal
Command. By
this command,
we can display
files name with
‘.txt’ extension
name.
DIR ?A*.* :- It is an Internal Command. By this command we can display the file name in the second letter is ‘A’.

 DIR *.SYS :- It is an Internal Command. By this command we can see the files name with .sys extension name.

Note:- ‘*’ (Asterisks) and ‘?’, these symbols are known as Wildcard Character. ‘.’ The symbol is different two names.
Like as Primary and Extension name.

 TYPE: – It is an Internal Command. By this command we can see the file content. (Which file do you want to see
just Input the file name)

• REN (Rename): – It is an Internal Command. This command is used to change the file name.

DEL (Delete): – It is an Internal Command. This command is used to delete any old file.

 MD (Make Directory): – It is an Internal Command. By this command we can create a new directory.

 CD: – It is an Internal Command. This command is used to enter any old directory to main path.

 CD.. :- It is an Internal Command. This command is used to exit last directory from main path.
 CD\ :- It is an Internal Command. This command is used to exit all directories from main path and come back
to main drive as prompt.

 RD (Remove Directory) :- It is an Internal Command. This command is used to delete any old directory.

Note:- All the above DOS commands are used in any drive. Like as- C:, E:, D: etc.

MS DOS External Commands

 EDIT: – It is an External Command. By this command we can edit/ modify the file content.

 ATTRIB: – It is an External Command. This command is used to hide and unhide any hidden file.

1. How to hide any file?


2. How to Unhide any file?
 TREE: – It
is an External
Command. By this
command we can
display the
directories name
with structure.
COPY: – It is an External Command. This command is used to copy file from any directory to another directory or
drive.

E.g. How to copy Washington.txt file to Africa directory?


XCOPY:- It is an External Command. By this command we can copy any file from any directory to another
directory drive or
directory much
faster than copy
command.

MORE:- It is an External Command. By this command we can display the file content up to 25 lines at a time then
continue. (pause after 25 lines)

 FC (File Compare): – It is an External Command. By this command we can display the different between two
file.

 CHKDSK: – It is an External Command. By this command we can check the status of disk.
 LABEL: – It is an External Command. By this command we can display and delete the current label.

 MOVE: – It is an External Command. This command is used to move any file to any drive.

 SORT: – It is an External Command. This command is used to sort the file.

 BATCH FILE: – It is an External Command. This command is used to display automation the DOS command. The
extension name of Batch file is ‘.bat’.
How to create a directory or folder
Updated: 01/24/2018 by Computer Hope

There are many different ways to create a folder, subfolder, directory, and subdirectory on
a computer depending on the operating system or where the directory is being created. Below are the steps on how to
create a directory and folder in all major operating systems.
 Creating a folder in Microsoft Windows
 Creating a directory in MS-DOS and the Windows command line
 Create a directory with a batch file
 Creating a directory in Linux and Unix
 Creating a directory in Microsoft Windows 3.X
 Creating a folder in macOS X
Creating a folder in Microsoft Windows

My Computer or Windows Explorer


1. Open My Computer or Windows Explorer
2. Open the drive or folder in which you'd like to create the new folder; for example, the C: drive. If you do
not want to create a folder in the root directory, browse to the location of your choosing.
3. In Windows 10 on the Home tab click the New folder icon. In Windows 7 and earlier on the file menu bar,
select File and then Folder.
Tip: In all versions of Windows you can also right-click with your mouse on a blank portion of the folder,
click New and then Folder, as shown in the image below.
Note: If you're using Windows 7 or earlier and do not see the File menu bar at the top of Windows Explorer, press
the Alt key and it should become visible.

Windows Desktop
1. Navigate to the Windows Desktop.
2. Right-click with your mouse on any blank portion of the Desktop.
3. In the menu that appears (like that shown in the picture to the right), click New and then Folder.
4. A new folder will appear. Type the name of the folder you want to use and then press Enter.
Create a new folder using a shortcut key
While in Windows Explorer you can press Ctrl+Shift+N to create a new folder without using the mouse.
Windows command line
See the following MS-DOS and Windows command line users section for information about creating a directory in the
Windows command line.
Creating a directory in MS-DOS and the Windows command line

Tip: It is more appropriate to use "directory" instead of "folder" when referring to the command line.
To create a directory in MS-DOS or the Windows command line, use the md or mkdir MS-DOS command. For example,
below we are creating a new directory called "hope" in the current directory.
mkdir hope

You can also create multiple new directories in the current directory by using the mdcommand. In the next example,
we are creating three new directories, called "user1", "user2", and "user3", in the current directory.
md user1 user2 user3

If you want to create a directory with spaces you need to surround the directory name with quotes. In the example
below, we are creating a directory called "my example directory" in the current directory.
md "my example directory"

To create a directory in the parent directory, without first moving into that directory, you can use the command below.
This example moves back one directory to create the "example" directory.
md ..\example

To create a subdirectory in a different directory without moving into it, use a command similar to the example below,
which creates a "test" directory in the hope directory.
mkdir hope\test

Tip: Once a directory has been created you can use the cd command to change the directory and move into that
directory.
To make a directory in another drive without moving into that drive you could use a command similar to the example
below, which creates an "example" directory on the F: drive. The drive letter "f:" can be substituted from any drive
letter.
md f:\example

Related pages
 How to use the Window command line (DOS).
 How to get to an MS-DOS prompt or Windows command line.
Create a directory with a batch file

A batch file is a series of commands that can be entered in the command line. Therefore you can use any of the
examples given in the above section on how to create a folder in the MS-DOS and Windows command line in the batch
file to create a new folder.
Creating a directory in Linux, Unix, and their variants

Tip: It is more appropriate to use "directory" instead of "folder" when in a command line.
Note: You must have the permissions to create a directory outside of your home directory.
To create a directory in Linux, Unix, or any variant, use the mkdir Linux and Unix command. For example, below we
are creating a new directory called hope in the current directory.
mkdir hope

Tip: Once the directory has been created you can use the cd command to change the directory and move into that
directory.
Tip: If you want to change the permissions of a directory after it has been created use the chmod command.
 Linux and Unix shell tutorial
Creating a folder and directory in Microsoft Windows 3.X

File Manager
1. Open File Manager
2. Open the folder in which you'd like to place the new folder and in the menu at the top of File Manager,
select File and then new folder.
MS-DOS
See the above MS-DOS users section for information about creating a directory in MS-DOS.
Creating a folder in macOS X

Desktop Folder
1. Navigate to the macOS desktop.
2. Right-click (tap two fingers on the mouse) any blank space on the desktop.
3. Select New Folder from the drop-down menu that appears.
4. Name the folder and then press Return.
Create a folder in a directory
1. Open Finder and navigate to the directory in which you'd like to create the folder.
2. Click on File in the upper left-hand corner of the screen.
3. Select New Folder in the drop-down menu that appears.
4. Name the folder, and then press Return.
Tip: Users may also press the shortcut key combination Command+Shift+N to create a new folder.
How to change a directory or folder
Updated: 01/24/2018 by Computer Hope

Below is additional information about how to change the directory or folder while working on a computer. Click on the
below operating system you are looking for information on how to change directories or folders.
 Microsoft Windows
 MS-DOS and Windows command line
 Linux and Unix
Microsoft Windows

To change or open directories (folders) while in Microsoft Windows, open either My Computer or Windows Explorer and
double-click the folder you want to move into. For example, if you wanted to move into the "Boot" folder of the current
"Windows" folder shown in the picture below, you would double-click the "Boot" folder. You can also right-click on
the "Boot" folder and select Open in the pop-up menu.

If you want to go back to the previous folder you can hit the back arrow (arrow pointing to the left), or click the name
of the location in the path you want to move. For example, in the above picture the path is "This PC > Local Disk (C:) >
Windows", to get back to the C: drive we would click "Local Disk C:"
Tip: You can also use the back button (thumb button) on your mouse to move back a folder.
Tip: Microsoft Windows users can also change directories at the Windows command line (MS-DOS) as explained below.
MS-DOS and the Windows command line

To change directories while in MS-DOS or the Windows command line use the cd command. Below are some basic
examples of how this command can be used to change directories.
 How to get to an MS-DOS prompt or Windows command line.

Before changing directories, you need to know what


directories are available in the current directory. To do this, use the dir command. For example, type the below
command to only list directories in the current directory.
dir /ad

See the dir command page for further information and examples of this command. In the picture is an example of
the tree command that list all directories and subdirectories from your current location.
Once you have a directory name, type a command similar to the command below, which is moving into the Windows
directory.
cd windows

If you need to move into multiple directories with one command, you can use a command similar to the example
below. In this example, the command would move into the system directory, which is a subdirectory of the Windows
directory.
cd windows\system

If you need to move back a directory (parent directory), you can use the below command. For example, if you were in
the Windows directory when you typed this command, it would move you back one directory to the C:\ directory.
cd..

If you were in more than one directory (e.g., C:\Windows\System32) and wanted to move back to the root directory,
you could use the below command.
cd\

Linux and Unix

To change directories while in a *nix environment, use the cd command. Below are some basic examples of how this
command can be used to change directories.
Before changing directories, you need to know what directories are available in the current directory. To do this, use
the ls command. For example, type the below command to only list directories in the current directory.
ls -d */

See the ls command page for further information and examples of this command. Once you know the directory is
available, type a command similar to the below command. The example below changes into the public_html directory.
cd public_html

If you need to move into a subdirectory with one command, you can use a command similar to the example below. In
the example below, the command would move into the cgi-bin directory, which is in the public_html directory.
cd public_html/cgi-bin
If you need to move back a directory (parent directory), you can use the below command. For example, if you were in
the public_html directory when you typed this command, it would move you back into the home directory.
cd ..

Note: There must be a space between cd and the two periods.


If you were in more than one directory (e.g., public_html/cgi-bin) and wanted to move back to the home directory, you
could use the below command.
cd ~

If instead of opening the home directory you wanted to return to the root directory, you could use the below command.
cd /

How to delete a file, directory, or folder


Updated: 01/24/2018 by Computer Hope
If you are looking to delete a file, directory, or folder, the steps vary depending on

the method you'd like to use, as well as your operating system. To


proceed, choose from the list of options below and follow the instructions.
 Microsoft Windows
 MS-DOS and Windows command line
 Linux, Unix, and variant
 macOS
 Microsoft Windows 3.X
How to delete files in Microsoft Windows

Microsoft Windows users can delete a file or folder (directory) using many different methods. Below are the more
common methods for deleting a file or folder.
Note: Users not familiar with Windows should realize that if you delete a folder, it will delete all the files and folders
within that folder.
Tip: The steps below are for deleting a single file or folder. However, the same steps can be done to delete multiple
files or folders if you select more than one file.
Delete key
The easiest way to delete files and folders is to locate the item you want to delete, highlight it by clicking on the file or
folder once, and then press the delete key on the keyboard. You can browse to the location of the file or folder using
either My Computeror Windows Explorer.
Tip: You can delete multiple files or folders by holding down the Control key and clicking each before pressing Delete.
Tip: You can hold down the Shift key while pressing the delete key to prevent the files being deleted from going to the
Recycle Bin.

Delete file or folder by right-clicking


Open My Computer or Windows Explorer. Locate the file or folder you want to delete and right-click it. Choose the
delete option from the pop-up menu.
Delete from File menu
Open My Computer or Windows Explorer, locate the file or folder you want to delete, click File in the top menu bar and
select Delete.
Tip: If the File menu is not visible in My Computer or Windows Explorer, press the Altkey to make the menu bar
visible, including the File menu.
Problems during delete
Some files and folders may be protected from deletion through encryption or password protection. In this case, you
may be asked for a password to decrypt or remove the password protection.
A file may be set as a read-only file, meaning it can only be opened for viewing, but it cannot be modified or deleted.
When trying to delete a read-only file, you will get a message stating the file is write protected and cannot be deleted.
Some files may only be deleted with administrator permissions. To delete these files, you would need to
have administrator rights on the computer. If you are using a work computer, the technical support staff often are the
only users with administrator rights on the computer.
Another possible cause of problems with deleting a file or folder is a virus or malwareinfection. Viruses and malware
can prevent files or folders from being modified or deleted. If this is the case, you need to remove the virus or
malware infection to be able to delete the affected file or folder.
 Cannot delete file because it's being used by another person or program.

Windows command line


See the below MS-DOS and Windows command line section for information about deleting a file or folder at the
Windows command line.
Uninstalling a program
See our uninstalling a program steps for help with uninstalling (deleting) software programs from the computer.
How to restore a deleted file or folder
If you've deleted a file by mistake you can see our steps on how to restore a deleted filepage for further information
on recovering a deleted file.
How to delete files in MS-DOS and the Windows command line

Note: Keep in mind that any deleted file or directory in MS-DOS will not be sent to the Windows Recycle Bin.
Before any of the steps below can be followed, you must get to an MS-DOS prompt or the Windows command line. If
you are new to the command line you may also want to go through our How to use the Windows command line
(DOS) tutorial.

Files
MS-DOS users can delete files using the del command. See this page to get additional information and help with this
command. Below is an example of how this command could be used.
del example.txt

As seen in the above example, when deleting a file, you need to enter the full file name including the file extension.
Delete multiple files
You can also use wildcards if you want to delete multiple files as shown in the example below.
del *.txt

In the above example, this command would delete all files that end with a .txt file extension.
Directory
MS-DOS users can delete directories in MS-DOS using the deltree command or rmdir command. See either of these
links for additional information about these commands. Below is an example of how this could be used.
rmdir example

Note: If the directory is full or has other sub directories, you will get an error message. To delete a full directory, you
need to use a switch with the above example. For example, "rmdir example /s" to remove a full "example" directory.
See our deltree command or rmdir command for additional examples and switches.
 Deleting files in MS-DOS without a prompt.

Deleting a subdirectory
If you want to delete a directory within another directory (subdirectory), you can use a command similar to the
example below.
rmdir example\test

In the above example, the "test" directory within the "example" directory would be deleted. You could also use the cd
command to change the directory to the example directory and then delete the "test" directory using our first example
shown above.
How to delete a directory or file name with a space
To delete a directory or file name with a space in the name, you must surround the directory or file name
with quotes as shown below.
del "my example file.txt"

rmdir "my example directory"

In the above examples, we are deleting the file named "my example file.txt" with quotes surrounding the complete
file name and extension and removing the "my example directory" directory.
 How to use the Window command line (DOS)
How to delete files in Linux, Unix, and other variants

Files
Linux and Unix users can delete files through the console by using the rm command. See this page for additional
information about this command. Below is an example of how this command could be used.
rm example.txt

As seen in the above example, when deleting a file, you need to enter the full file name including the file extension.
Delete multiple files
You can also use wildcards if you want to delete multiple files as shown in the example below.
rm *.txt

In the above example, this command would delete all files that end with a .txt file extension.
Directory
Linux and Unix users can delete folders through the console by using the rmdir command. See this page for additional
information about this command. Below is an example of how this command could be used.
rmdir example

Tip: Like Microsoft Windows, with Linux and Unix, you can also delete files through the GUI by locating the file and
pressing the delete key on the keyboard.
Deleting a subdirectory
If you want to delete a directory within another directory (subdirectory) you can use a command similar to the example
below.
rmdir example\test

In the above example, the "test" directory within the "example" directory would be deleted. You could also use the cd
command to change the directory to the example directory and then delete the "test" directory using our first example
shown above.
How to delete a directory or file name with a space
To delete a directory or file name with a space in the name you must surround the directory or file name
with quotes as shown below.
rm "my example file.txt"

rmdir "my example directory"

In the above examples we are deleting the file named "my example file.txt" with quotes surrounding the complete file
name and extension and removing the "my example directory" directory.
 How do I remove a full directory in Linux?
 Linux and Unix shell tutorial.
How to delete files on macOS

Apple macOS users can delete a file or folder (directory) using many different methods. Below are the more common
methods for deleting a file or folder.
Note: Users not familiar with Apple macOS should realize that if you delete a folder, it will delete all the files and
folders within that folder.
Tip: The steps below are for deleting a single file or folder. However, the same steps can be applied to delete multiple
files or folders if you select several of them first.
Delete key
The easiest way to delete files and folders is to locate the item you want to delete, highlight it by clicking on the file or
folder once, and then press the delete key on the keyboard. You can browse to the location of the file or folder using
either My Computeror Windows Explorer.
Delete file or folder by right-clicking it, and choosing Delete
Open My Computer or Windows Explorer. Locate the file or folder you want to delete and right-click it. Choose the
delete option from the pop-up menu.
Delete from File menu
Open My Computer or Windows Explorer, locate the file or folder you want to delete, click File in the top menu bar and
select Delete.
Tip: If the File menu is not visible in My Computer or Windows Explorer, press the Alt key to make the menu bar
visible, including the File menu.
Terminal
To delete files or directories in the Terminal command line, use the rm command.
How to delete files on Microsoft Windows 3.X

File Manager
1. Open File manager
2. Locate the folder or file you want to delete, then click File and Delete.
MS-DOS
See the above MS-DOS users section for information about deleting a directory in MS-DOS.

How to copy files


Updated: 01/24/2018 by Computer Hope

Below are the steps required to copy computer documents, pictures, or other files from one source to another. Click on
one of the links below to scroll down automatically to the operating system you need help with or scroll down to
review them all.
Note: When copying files, you are going to get more than one copy of the file on your computer. If you want only one
copy of the files, you should move the files.
Note: If you make a copy of a file in the same directory or folder that the original file is located, the copied file will
have a number appended to the end of the file name. Within a single directory or folder, a file name must be unique.
Appending a number to the end of the copied file's name assures the copied file is unique. For example, if the original
file name is abc123.pdf and a copy of the file is created in the same directory or folder, the copied file name could be
abc123(1).pdf or abc123~1.pdf.
 Microsoft Windows
 MS-DOS and Windows command line
 Batch file
 Linux and Unix
 Apple macOS
How to copy a file in Microsoft Windows

Below are the simple steps on how to copy a file or multiple files
in Microsoft Windows from one location to another.
1. Go to the files or folders you want to copy. If you need help locating the files use the Windows find
feature.
2. Highlight the file or files you want to copy by clicking them once with the mouse. If you need to highlight
more than one file, you can hold down the Ctrl or Shift keys on your keyboard or drag a box around the
files you want to copy.
3. Once highlighted, right-click one of the highlighted files and select copy. Users may also press the
Ctrl+C shortcut key, or in Windows Explorer, click Edit at the top of the window and choose Copy.
4. Move to the drive, folder, or other location you want to copy the files to and either right-click in the folder
and choose paste or click Edit from the File Menu and then click Paste.
 How do I select or highlight multiple files?

Tip: If you want to copy only a certain type of file you can click on the Type column in Windows Explorer to sort the
files by the type and not by the name. Once grouped by type you can select only the files with the type you want to
copy and copy those files.
Tip: You can also use the Windows command line (mentioned below) to copy files. In some situations, such as copying
multiple files of a certain extension or with a certain name, it can be a lot easier.
How to copy a file in MS-DOS and the Windows command line

Below are steps on how to copy a single file from one directory to
another directory as well as how to copy multiple files from one directory to another directory.
Copying a single file
1. Using the cd command, move to the directory that contains the file you want to copy.
2. Type a command similar to the below command.
copy myfile.txt c:\my\location

In the above example, you would substitute "myfile.txt" with the name of the file you want to copy, and
"c:\my\location" with the destination directory.
Copying multiple files to another location
1. Using the cd command, move to the directory that contains the files you want to copy.
2. Once in the directory that contains the files you want to copy, type a command similar to one of the below
commands.
copy *.* c:\mydir

In the above example, the command would copy every file in the current directory to the "mydir" directory.
copy *.txt c:\mydir

In the above example, the command would copy every txt, or text file, in the current directory into the "mydir"
directory.
Tip: Additional examples of wildcard characters can be found on our wildcarddefinition.
xcopy hope example /e

If you need to copy files, directories, and subdirectories use the xcopy command. In the above example, this xcopy
command copies all directories (even empty directories) and files from the hope directory into the example directory.
Copying long file name files or files with spaces
Many times you will encounter a file with spaces in the file name. To copy these files surround the full file name
and file extension in quotes as shown below.
copy "computer hope.txt" "there is hope.txt"

In the above example, the "computer hope.txt" file is surrounded in quotes to let the command line know the complete
file. In our example we are also copying the file to a file name with spaces so it is also surrounded in quotes.
How to copy files to another drive
You can also copy files from the current location to any other drive. For example, if you have a USB flash drive that
is drive letter F: you can use the command below to copy the file all JPEG image files to the flash drive.
copy *.jpg f:

 How to change drives in MS-DOS and Windows command line.


How to make a copy of a file into the same directory
copy example.txt backup.txt

In the above example, the file "example.txt" is copied into the same directory as "backup.txt", effectively making
a backup copy of the file.
Related pages and help
 See the cd command, dir command, copy command, and xcopy command pages for further information about
each of these MS-DOS commands.
 How to use the Window command line (DOS)
Batch file

To perform any copy command in a batch file include any of the above Windows command line copy commands in a
batch file.
 How to make a batch file.
How to copy files in Linux and Unix

Below are steps on how to copy a single file from one directory to
another directory as well as how to copy multiple files from one directory to another directory.
Copying a single file from one location to another.
1. Using the cd command, move to the directory that contains the file you want to copy.
2. Type a command similar to the below command.
cp myfile.txt /usr/bin

In the above example, you would substitute "myfile.txt" with the name of the file you want to copy, and "/usr/bin"
with the destination directory.
Copying multiple files to another location
1. Using the cd command, move to the directory that contains the files you want to copy.
2. Once in the directory that contains the files you want to copy, type a command similar to one of the below
commands.
cp *.* /usr/bin

In the above example, the command would copy every file in the current directory to the "/usr/bin" directory.
cp *.txt /usr/bin

In the above example, the command would copy every txt, or text file, in the current directory into the "/usr/bin"
directory.
Additional examples of wildcard characters can be found on our wildcard definition.
Copying files with spaces in the file names
Many times you will encounter a file with spaces in the file name. To copy these files surround the full file name
and file extension in quotes as shown below.
cp "computer hope.txt" "there is hope.txt"

In the above example, the "computer hope.txt" file is surrounded in quotes to let the command line know the complete
file. In our example we are also copying the file to a file name with spaces so it is also surrounded in quotes.
How to make a copy of a file into the same directory
cp example.txt backup.txt

In the above example, the file "example.txt" is copied into the same directory as "backup.txt", effectively making
a backup copy of the file.
Related pages and help
 See the cd command, cp command, and ls command pages for additional information about each of these
commands.
 Linux and Unix shell tutorial
How to copy files in Apple macOS

Drag-and-drop
Highlight the files you want to copy, click with your left mouse button and while continuing to hold down the
button drag-and-drop the files to where you want to copy them. When you release the mouse button, the files are
copied.
Keyboard shortcut
You can also copy files using keyboard shortcuts by following the steps below.
1. Highlight the files you want to copy.
2. Press the keyboard shortcut Command + C.
3. Move to the location you want to move the files and press Command + V to copy the files.
Terminal
To copy files in the Terminal command line use the cp command.

You might also like