XCOPY: Copies files and directory trees.


 


... The examples for the command "XCOPY"
... "XCOPY" Excerpt from Microsoft Windows Help
... Important information, tips for the "XCOPY" command

The command: "XCOPY" is on Windows 12, 11, 10, .. , MS Server 2025, 2022, 2019, .. available

The examples for the command "XCOPY"

The `XCOPY` command in Windows Command Prompt is used to copy files and directories from a source location to a destination location. Here are some examples: Example 1: Simple file copying:

XCOPY C:\Source\File.txt D:\Destination\

Description: This example copies the file "File.txt" from the source location `C:\Source\` to the `D:\Destination\` directory. Example 2: Copying files and subdirectories using recursive copy:

XCOPY C:\Source\*.* D:\Destination\ /S /E

Description: Here all files and subdirectories from `C:\Source\` are copied to the `D:\Destination\` directory. The `/S` and `/E` options ensure that subdirectories and empty subdirectories are also copied. Hints: 1. `XCOPY` provides many options and switches for different copy scenarios. You can use `XCOPY /?` to see a list of available options. 2. If you want to copy a directory, you can use `XCOPY` with the `/I` option to indicate that the destination location is a directory.

   XCOPY C:\Source\ D:\Destination\ /I
   
3. `XCOPY` also supports copying files based on specific criteria such as file date or file size.

   XCOPY C:\Source\*.txt D:\Destination\ /D:01-01-2023
   
Only text files that were changed after January 1, 2023 are copied here. Example 3: Use in a batch script:

@ECHO OFF
XCOPY C:\Source\*.* D:\Destination\ /S /E
REM rest of the batch script

Description: Here `XCOPY` is used in a batch script to copy files and directories. Example 4: Interactive copying with confirmations:

XCOPY C:\Source\*.* D:\Destination\ /S /E /P

Description: By adding the `/P` option, `XCOPY` will ask the user for confirmations for each item to be copied. It is important to note that `XCOPY` provides a powerful way to copy files and directories, and the exact use of it depends on the specific needs of the copy operation.

"XCOPY" Excerpt from Microsoft Windows Help

Microsoft Windows [Version 10.0.19045.3693]
(c) Copyright 1985-2023 Microsoft Corp.

C:\\WINDOWS>

Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
                           [/EXCLUDE:file1[+file2][+file3]...]

  source       Specifies the file(s) to copy.
  destination  Specifies the location and/or name of new files.
  /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     Copies files changed on or after the specified date.
               If no date is given, copies only those files whose
               source time is newer than the destination time.
  /EXCLUDE:file1[+file2][+file3]...
               Specifies a list of files containing strings.  Each string
               should be in a separate line in the files.  When any of the
               strings match any part of the absolute path of the file to be
               copied, that file will be excluded from being copied.  For
               example, specifying a string like \obj\ or .obj will exclude
               all files underneath the directory obj or all files with the
               .obj extension respectively.
  /P           Prompts you before creating each destination file.
  /S           Copies directories and subdirectories except empty ones.
  /E           Copies directories and subdirectories, including empty ones.
               Same as /S /E. May be used to modify /T.
  /V           Verifies each new file.
  /W           Prompts you to press a key before copying.
  /C           Continues copying even if errors occur.
  /I           If destination does not exist and copying more than one file,
               assumes that destination must be a directory.
  /Q           Does not display file names while copying.
  /F           Displays full source and destination file names while copying.
  /L           Displays files that would be copied.
  /G           Allows the copying of encrypted files to destination that does
               not support encryption.
  /H           Copies hidden and system files also.
  /R           Overwrites read-only files.
  /T           Creates directory structure, but does not copy files. Does not
               include empty directories or subdirectories. /T /E includes
               empty directories and subdirectories.
  /U           Copies only files that already exist in destination.
  /K           Copies attributes. Normal Xcopy will reset read-only attributes.
  /N           Copies using the generated short names.
  /O           Copies file ownership and ACL information.
  /X           Copies file audit settings (implies /O).
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

Important information, tips for the "XCOPY" command

There are a few important aspects to note when using the `XCOPY` command in the Windows Command Prompt: 1. Options and Switches: `XCOPY` provides a variety of options and switches that support various copy scenarios. You can use `XCOPY /?` to display a help screen with the available options. 2. Path Information: The source and destination information in `XCOPY` should be correct paths. Make sure to enclose the paths in quotation marks, especially if they contain spaces.

   XCOPY "C:\Source\*" "D:\Destination\" /S /E
   
3. Recursive copy: If you want to copy files and subdirectories, use the `/S` (include subdirectories) and `/E` (include empty subdirectories) options.

   XCOPY C:\Source\*.* D:\Destination\ /S /E
   
4. Confirmations: Use the `/P` option if you want to receive a confirmation before each copy operation.

   XCOPY C:\Source\*.* D:\Destination\ /P
   
5. Copy files based on criteria: `XCOPY` allows copying files based on specific criteria such as file date or file size.

   XCOPY C:\Source\*.txt D:\Destination\ /D:01-01-2023
   
Only text files that were changed after January 1, 2023 are copied here. 6. Use in batch scripts: `XCOPY` is often used in batch scripts to copy files and directories. Make sure the batch script is running in the correct environment.

   @ECHO OFF
   XCOPY C:\Source\*.* D:\Destination\ /S /E
   REM rest of the batch script
   
7. Permissions: Make sure that the user executing the `XCOPY` command has the required permissions on the source and destination directories. 8. File Conflicts: If files with the same names already exist in the target directory, `XCOPY` may react differently depending on the options chosen. By default, you will be asked when file conflicts occur.

   XCOPY C:\Source\*.* D:\Destination\ /S /E /Y
   
Here the `/Y` option is used to suppress all queries. It is important to understand the specific needs of your copy operation and adjust the `XCOPY` options accordingly. Also note that there are alternative methods to copy files in the Windows environment, such as `COPY`, `ROBOCOPY` and `COPY-ITEM` in PowerShell.


Deutsch
English
Español
Français
Italiano
日本語 (Nihongo)
한국어 (Hangugeo)
汉语 (Hànyǔ)
Türkçe
Português
Português
Svenska
Norsk
Dansk
Suomi
Nederlands
Polski









Windows-10


... Windows 10 FAQ
... Windows 10 How To


Windows 10 How To


... Windows 11 How To
... Windows 10 FAQ



The command XCOPY - Copies files and directory trees.

HTTP: ... console13.000000ko0.000000index.htm/en/071.htm
0.093
13822
Update Group Policy on MS Windows OS!
Unterschied prozentuelle Bildverkleinerung und Größe anpassen an Bildbreite!
Enable background color for the digital desktop clock on Windows?
Be my patron on Software OK!
Why is my Intel HD graphics card slower than the others?
How can I uninstall the Experience-Index-OK from Windows 11, 10, ...?
For what snow on the desktop, who needs something like that?
Search for/in text using regular expressions (Regex)?
I don't want a watermark on my scaled down vacation photos!
The autopilot and the benchmark, what's the difference?



(0)