DOS Command: XCOPY (2024)



XCOPY


Type: External (3.2 and later)

Syntax:

XCOPY [d:][path]filename [d:][path][filename] [/A][/D:(date)] [/E][/M][/P]
[/S][/V][/W][Y|-Y]

Purpose: Copies directories, subdirectories, and files.

Discussion

XCOPY copies files or groups of files to and from directories. Especially useful for copying data to and from a fixed disk.

The first path designation specifies the source file(s); the second path designation specifies the target file(s). A source designation must always be provided. If you do not enter a target designation, files will be copied to thecurrent directory.

This command provides a way to copy entire disks full of data, including all established directories and subdirectories. This command should be used insteadof the DISKCOPY command when you want to create a disk with identical file structures, but with a different disk format (for example, to copy all files from a 5 1/4 inch disk to a 3 1/2 inch disk).

If the source is a directory, the directory will be copied onto the destination diskette. If the source to be copied includes more than one file, the destination files will be stored in a directory. You can add a backslash (\) tothe end of the destination filename to make it a directory.

If XCOPY does not find a directory on the destination disk that matches a PATH specification in the command format, the copying will stop. A message will be displayed asking you to specify whether or not the destination file specification is to be stored as a filename or a directory name.

XCOPY is a much more powerful copying command than the COPY command. It is especially useful when backing up your fixed disk. A common usage would be to use the /S option along with the /D:date option to back up only the files that have been changed since the date of your last backup. If you are using XCOPY for this purpose, you will probably want to make a copy of the program (XCOPY.EXE) in the root directory of your fixed disk (remember, when you use the/S option, XCOPY only copies files from subdirectories found WITHIN the current directory).

After you enter the XCOPY command, the program may display
Does TST specify a file name

or directory name on the target

(F = file, D = directory)

This means XCOPY cannot determine if you want the specified path designation entry to be sent to a filename on the target disk or to a directory.

NOTE:

Some versions of DOS provide a way to avoid this prompt. It is done by renamingthe XCOPY.EXE command to MCOPY.EXE. When using MCOPY, DOS will automatically check to determine if the target is a filename or a directory name and carry outthe copy accordingly. To change the name of the command to MCOPY, enter

copy xcopy.exe mcopy.exe

Then, you can use the new MCOPY.EXE program just as you would use XCOPY.EXE. The only difference is that MCOPY will automatically determine whether the target is to be a file or a directory.

See Also
xcopy

If an error is encountered during the XCOPY process, the program returns one of the following exit codes:

0 - Copying was completed without error
1 - No files found
2 - User terminated the copy
4 - Initialization error (not enough memory, invalid syntax, path not found)
5 - Copy terminated due to INT 24 error reading or writing disk

For more information on using the XCOPY command, refer to Chapter 6, Tips for Advanced Users.

Options

/A - Copies only files that have been set as archive files (using the ATTRIBcommand). The copied files will still be marked as archive files in BOTH the source and destination files.

/D:(date) - Copies only those files in the source directory that have been changed on or LATER than the specified date.

/S - Copies all files in the current directory and in any subdirectory within it.

/E - Copies subdirectories, even if they are empty. If you use this option, you must use the /S option also.

/M - Copies the same marked archive files as specified in the /A option; however, the files on the destination disk are no longer marked as archive files. This switch checks the archive attribute of a file: if the file`s archive attribute is set to off (-A), the file will not be copied.

/P - Does not copy the file until you respond to a prompt that asks you to confirm that you want the file copied. However, if you are using the /E option,you will not be prompted before an empty subdirectory is copied.

/V - Each file copied is verified to be sure the file stored on the destination disk is identical to the original on the source disk.

/W - Copies only after you respond to a prompt to begin copying (if this option is omitted, the copying begins as soon as you enter the XCOPY command andpress the Enter key).

/Y - Causes XCOPY to replace existing files without a confirmation prompt.

/-Y - Causes XCOPY to give you a confirmation prompt before replacing an existing file.

Example

To copy all files and directories (except empty directories) from drive C to drive A, enter

xcopy c: a: /s

Back to the Easy DOS Command Index

DOS Command:  XCOPY (2024)

FAQs

DOS Command: XCOPY? ›

Purpose: Copies directories, subdirectories, and files. XCOPY copies files or groups of files to and from directories. Especially useful for copying data to and from a fixed disk. The first path designation specifies the source file(s); the second path designation specifies the target file(s).

How to use xcopy command in cmd? ›

How to Use Xcopy Command to Copy Folders and Subfolders
  1. xcopy [source] [destination] [options]
  2. Xcopy C:\example D:\example /E /H /C /I.
  3. Xcopy Source Destination /T /E.
  4. Xcopy Source Destination /O /X /E /H /K.

What is the difference between xcopy and copy command? ›

Starting with the definitions, the "copy" command is used for copying files or data, and "Xcopy" is used to copy multiple files or complete directory trees from one directory to another, etc.

How do you copy using DOS command? ›

COPY
  1. Type: Internal (1.0 and later)
  2. Syntax: COPY [/Y|-Y] [/A][/B] [d:][path]filename [/A][/B] [d:][path][filename] [/V] ...
  3. Purpose: Copies or appends files. Files can be copied with the same name or with a new name.
  4. Discussion. COPY is usually used to copy one or more files from one location to another. ...
  5. Options. ...
  6. Examples.

Does xcopy copy hidden files? ›

The command doesn't copy hidden files or system files by default but will when using this option. Use the /i option to force xcopy to assume that destination is a directory.

How do I copy an entire drive using xcopy? ›

Method 1. Using Xcopy Command to Clone Hard Drive
  1. Go to Start and type "cmd" into the search box. Then select Command Prompt (Admin) to open CMD.
  2. Type down xcopy c:\ f:\ /s /e /h /i /c /y and then press Enter to copy all files and subdirectories from drive C to drive D. ...
  3. Wait for the process to be complete.

How to copy text from CMD? ›

Right click anywhere inside the Command Prompt window and select Mark from the popup menu. Use the left mouse button to highlight the text to be copied and then press Enter on the keyboard to copy it. The text can now be pasted into any text box or document by right clicking and selecting Paste.

Is xcopy obsolete? ›

While still included in Windows 10, XCOPY has been deprecated in favor of robocopy , a more powerful copy tool, which is now supplied with the Microsoft Windows Server and Desktop operating systems.

How do I force xcopy to copy a file? ›

Press F if you want the file or files to be copied to a file. Press D if you want the file or files to be copied to a directory. You can suppress this message by using the /i command-line option, which causes xcopy to assume that the destination is a directory if the source is more than one file or a directory.

Why is xcopy not copying everything? ›

If you are not using XCOPY with administrator rights, you may lack permission to read the contents of some files. Therefore, XCOPY will be unable to copy the file due to a lack of permission to read the file's data. If you encounter this problem, you can use XCOPY with administrator rights.

How to copy data using CMD? ›

Open CMD (admin) using the start button. Enter the Xcopy command to copy folders and subfolders, with their contents, as presented below. /E- Duplicates all subdirectories, containing any that are empty. /H- Duplicates files that are hidden or have system file attributes.

How fast is xcopy? ›

Robocopy vs. XCopy File Copy Performance
Performance CounterRobocopyXCopy
Disk Transfer Rate128.48 MB/Sec121.06 MB/Sec
Disk Read Transfer75.28 MB/Sec76.15 MB/Sec
Disk Write Transfer50.30 MB/Sec43.76 MB/Sec
Disk Transfer IOPS3701.72 IOPS2860.24 IOPS
14 more rows

How do I copy a disk in DOS? ›

The diskcopy command prompts you to insert the source and destination disks and waits for you to press any key on the keyboard before continuing. Copy another diskette (Y/N)? If you press Y, diskcopy prompts you to insert source and destination disks for the next copy operation. To stop the diskcopy process, press N.

Should I use copy or xcopy? ›

XCOPY is a much more powerful copying command than the COPY command. It is especially useful when backing up your fixed disk. A common usage would be to use the /S option along with the /D:date option to back up only the files that have been changed since the date of your last backup.

How does xcopy work? ›

Copies files from Source that exist on Destination only. If Source is a directory or contains wildcards and Destination does not exist, xcopy assumes Destination specifies a directory name and creates a new directory. Then, xcopy copies all specified files into the new directory.

Is Robocopy better than xcopy? ›

Robocopy can work even faster with a few command lines when given appropriately. Xcopy performs slightly better on Disk Read Transfer but worse on other aspects than Robocopy. Although, if a user has a powerful computer and a good network, it can increase the copying speed.

How to copy a file using CMD? ›

Open the Command Prompt by searching for 'cmd' in the Windows Search box. Navigate to the directory where the files are located using the 'cd' command. Type in 'copy' followed by the filename and destination path.

How to move files using CMD? ›

move cmd command
  1. [drive:][path]filename1 – Specifies the location and name of the file or files you want to move.
  2. destination – Specifies the new location of the file. ...
  3. [drive:][path]dirname1 – Specifies the directory you want to rename.
  4. dirname2 – Specifies the new name of the directory.
  5. /Y – ...
  6. /Y –
Oct 20, 2020

How to use the for command in CMD? ›

Use a single percent sign ( % ) to carry out the for command at the command prompt. Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c.

How to import from CMD? ›

To import data through command line:
  1. To open Command Prompt, press Win+R and type cmd in the Open line.
  2. Type a path to the datapump. ...
  3. Specify the operation you want to perform (data import) and the template file: ...
  4. Type all other arguments you need.
  5. Press ENTER to run the process.

Top Articles
2018 Paddington Bear at Buckingham Palace BU 50p | Chards
Max Pooling
Poe T4 Aisling
Minooka Channahon Patch
Melson Funeral Services Obituaries
Odawa Hypixel
Craftsman M230 Lawn Mower Oil Change
News - Rachel Stevens at RachelStevens.com
His Lost Lycan Luna Chapter 5
Emmalangevin Fanhouse Leak
Tlc Africa Deaths 2021
Which Is A Popular Southern Hemisphere Destination Microsoft Rewards
12 Best Craigslist Apps for Android and iOS (2024)
Edible Arrangements Keller
Skylar Vox Bra Size
Bjork & Zhulkie Funeral Home Obituaries
Five Day National Weather Forecast
Conan Exiles Thrall Master Build: Best Attributes, Armor, Skills, More
Chastity Brainwash
Beebe Portal Athena
Walmart stores in 6 states no longer provide single-use bags at checkout: Which states are next?
Hocus Pocus Showtimes Near Amstar Cinema 16 - Macon
Golden Abyss - Chapter 5 - Lunar_Angel
Bridge.trihealth
Empire Visionworks The Crossings Clifton Park Photos
Melendez Imports Menu
Dark Entreaty Ffxiv
Jordan Poyer Wiki
Integer Division Matlab
Wiseloan Login
Sienna
Criterion Dryer Review
Pixel Combat Unblocked
Healthy Kaiserpermanente Org Sign On
Delta Math Login With Google
LG UN90 65" 4K Smart UHD TV - 65UN9000AUJ | LG CA
Vip Lounge Odu
Restaurants Near Calvary Cemetery
L'alternativa - co*cktail Bar On The Pier
The 50 Best Albums of 2023
Los Garroberros Menu
Www Craigslist Com Brooklyn
Vocabulary Workshop Level B Unit 13 Choosing The Right Word
Updates on removal of DePaul encampment | Press Releases | News | Newsroom
Tricia Vacanti Obituary
Levi Ackerman Tattoo Ideas
Honkai Star Rail Aha Stuffed Toy
How To Get To Ultra Space Pixelmon
Paperlessemployee/Dollartree
Booknet.com Contract Marriage 2
Used Auto Parts in Houston 77013 | LKQ Pick Your Part
Latest Posts
Article information

Author: Greg Kuvalis

Last Updated:

Views: 6622

Rating: 4.4 / 5 (55 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Greg Kuvalis

Birthday: 1996-12-20

Address: 53157 Trantow Inlet, Townemouth, FL 92564-0267

Phone: +68218650356656

Job: IT Representative

Hobby: Knitting, Amateur radio, Skiing, Running, Mountain biking, Slacklining, Electronics

Introduction: My name is Greg Kuvalis, I am a witty, spotless, beautiful, charming, delightful, thankful, beautiful person who loves writing and wants to share my knowledge and understanding with you.