Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the hueman domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/future4tech/public_html/wp-includes/functions.php on line 6114
XCOPY – Windows CMD Command - Future4Tech

XCOPY – Windows CMD Command

Copy files and/or directory trees to another folder. XCOPY is similar to the COPY command except that it has additional switches to specify both the source and destination in detail.

While still included in Windows 10, Xcopy has been deprecated in favor of Robocopy, a more powerful copy tool, which is now built into Windows Server and Desktop operating systems.

Syntax
      XCOPY source [destination] [options]

Key
   source      : Pathname for the file(s) to be copied (accepts wildcards).

   destination : Pathname for the new file(s).
   
   [options] can be any combination of the following:
      
Source Options
      
   /A    Copy files with the archive attribute set (default=Y)

   /M    Copy files with the archive attribute set and
         turn off the archive attribute, use this option
         when making regular Backups (default=Y)
                                   
   /H    Copy hidden and system files and folders (default=N)

   /D:mm-dd-yyyy
         Copy files changed on or after the specified date.
         If no date is given, copy only files whose
         source date/time is newer than the destination time.

   /U    Copy only files that already exist in destination.
   
   /S    Copy folders and subfolders

   /E    Copy folders and subfolders, including Empty folders.
         can be used to modify /T.

   /EXCLUDE:file1[+file2][+file3]...

         The files can each contain one or more full or partial pathnames to be excluded.
         When any of these match any part of the absolute path of a SOURCE file, then 
         that file will be excluded.
         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.
               
Copy Options
               
   /W    Prompt you to press a key before starting to copy.
   /P    Prompt before creating each file.

   /Y    Suppress prompt to confirm overwriting a file.
         can be preset in the COPYCMD env variable.
   /-Y   Prompt to confirm overwriting a file.
   
   /V    Verify that the new files are readable.
   /C    Continue copying even if an error occurs.

   /B    Copy the Symbolic link itself, not the target of the file.

   /G    Allow the copying of encrypted files to a destination that does not support encryption.

   /J    Copy using unbuffered I/O. Recommended for very large files.
  
   /Q    Do not display file names while copying.
   /F    Display full source and destination file names while copying.
   /L    List only - Display files that would be copied.

   /Z    Copy files in restartable mode. If the copy is interrupted part way through,
         it will restart if possible. (use on slow networks)

Destination Options
 
   /I    If in doubt always assume the destination is a folder
         e.g. when the destination does not exist.

   /R    Overwrite read-only files.

   /T    Create folder structure, but do not copy files. 
         Do not include empty folders or subfolders. 
          /T /E will include empty folders and subfolders.

   /K    Copy attributes. XCOPY will otherwise reset read-only attributes.

   /N    If at all possible, use only a short filename (8.3) when creating
         a destination file. This can be necessary when copying between disks
         that are formatted differently e.g NTFS and VFAT, or when archiving 
         data to an ISO9660 CDROM.

   /O    Copy file Ownership and ACL information.

   /X    Copy file audit settings (implies /O).

XCOPY will accept UNC pathnames.

To always overwrite destination files use the COPYCMD environment variable: SET COPYCMD=/Y

When comparing Dates/Times the granularity (the finest increment of the timestamp) is 2 seconds for a FAT volume and 0.1 microsecond for an NTFS volume.

Copy a single file

In most cases copying a single file is best done with the COPY command. When copying a single file with XCOPY, there is no option to indicate if the destination is a filename or a directory (with the filename defaulting to that of the source file).
In such cases XCOPY will prompt with a (locale specific) message like:
C:\> xcopy foo.txt bar.txt
Does foo.txt specify a file name
or directory name on the target
(F = file, D = directory)?

Adding a wildcard (*) to the end of the destination will suppress this prompt and default to copying as a file:
C:\> xcopy foo.txt bar.txt*
C:foo.txt
1 File(s) copied
This requires the source and target file extensions to be the same length, typically 3 characters.

Insufficient Memory error

Attempting to XCOPY a source file that has a pathname longer than the Windows maximum path length (254 characters) will result in a rather unhelpful ‘Insufficient Memory’ error, the operation will then halt. This bug which has been around for over 10 years makes XCOPY a poor choice for any kind of backup script, use ROBOCOPY instead.

Exit Codes

0 Files were copied without error.

1 No files were found to copy.

2 The user pressed CTRL+C to terminate xcopy.

4 Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line.

5 Disk write error occurred.

Examples:

Copy a file:

echo F| XCOPY C:\utils\MyFile.txt D:\Backup\CopyFile.txt

Copy a folder:

XCOPY C:\utils D:\Backup\utils /i

Copy a folder including all subfolders.

XCOPY C:\utils\* D:\Backup\utils /s /i

You may also like...

4 Responses

  1. game nfts says:

    Hey would you mind letting me know which web host you’re utilizing?
    I’ve loaded your blog in 3 different internet browsers and I must say this blog loads a lot quicker then most.
    Can you suggest a good hosting provider at a honest price?
    Kudos, I appreciate it!

  2. zoritoler imol says:

    It’s really a great and useful piece of info. I’m glad that you shared this useful information with us. Please keep us up to date like this. Thanks for sharing.

  3. zortilo nrel says:

    I would like to thnkx for the efforts you have put in writing this blog. I am hoping the same high-grade blog post from you in the upcoming as well. In fact your creative writing abilities has inspired me to get my own blog now. Really the blogging is spreading its wings quickly. Your write up is a good example of it.

  4. frolep rotrem says:

    I genuinely enjoy examining on this website , it has fantastic articles.

Leave a Reply

Your email address will not be published. Required fields are marked *


Notice: ob_end_flush(): Failed to send buffer of zlib output compression (0) in /home/future4tech/public_html/wp-includes/functions.php on line 5464