Suppose for some reason your Windows computer is not running or is Infected with the virus. There are some important files in c drive and you need to copy them using the command line. In this post, we will discuss a nice function of Windows which is XCopy.
The XCopy is a Command Prompt command used to copy one or more files or folders from one location to another location. The XCopy command, with its many options and ability to copy entire directories, is similar to, but much more powerful than, the copy command. The Robocopy command is also similar to the xCopy but has even more options.
The XCopy is an excellent solution for syncing one folder to another. The XCopy is available from within the Command Prompt in all Windows operating systems including Windows 10. The advantages of XCOPY have been listed below:
- XCOPY can copy directories.
- XCOPY can exclude files based on file names or extensions.
- XCOPY will automatically delete the read-only attribute when copying files from the CDROM to the hard drive.
- XCOPY can recursively copy all files including subdirectories and can copy the source directory structure as it is.
- XCOPY can help identify updated files (based on archive attributes or based on the given expiration date), thus it is great for incremental backup needs.
Basic Example of XCopy
Use the following syntax for the XCopy:
xcopy C:\Files E:\Files /i
xcopy C:\Videos "\\SERVER\Media Backup" /f /j /s /w /z
XCopy Command Syntax
xcopy source [destination] [/a] [/b] [/c] [/d [:date]] [/e] [/f] [/g] [/h] [/i] [/j] [/k] [/l] [/m] [/n] [/o] [/p] [/q] [/r] [/s] [/t] [/u] [/v] [/w] [/x] [/y] [/-y] [/z] [/exclude:file1[+file2][+file3]…] [/?]
Xcopy Command Options
|This defines the files or top-level folder that you want to copy from. The source is the only required parameter in the xcopy. Use quotes around the source if it contains spaces.
|This option specifies the location where the source files or folders should be copied to. If no destination is listed, the files or folders will be copied to the same folder you run the xcopy from. Use quotes around the destination if it contains spaces.
|Using this option will only copy archive files found in the source. You can not use /a and /m together.
|Use this option to copy the symbolic link itself instead of the link target. This option was first available in Windows Vista.
|This option forces xcopy to continue even if it encounters an error.
|Use the xcopy with /d option and a specific date, in MM-DD-YYYY format, to copy files changed on or after that date. You can also use this option without specifying a specific date to copy only those files in a source that are newer than the same files that already exist in the destination. This is helpful when using the xcopy to perform regular file backups.
|When used alone or with /s, this option is the same as /s but will also create empty folders in a destination that were also empty in the source. The /e option can also be used together with the /t option to include empty directories and subdirectories found in the source in the directory structure created in the destination.
|This option will display the full path and file name of both the source and destination files being copied.
|Using the xcopy with this option allows you to copy encrypted files in source to a destination that does not support encryption. This option will not work when copying files from an EFS encrypted drive to a non-EFS encrypted drive.
|The xcopy does not copy hidden files or system files by default but will when using this option.
|Use the /i option to force xcopy to assume that the destination is a directory. If you don’t use this option, and you’re copying from a source that is a directory or group of files and copying to a destination that doesn’t exist, the xcopy will prompt you to enter whether a destination is a file or directory.
|This option copies files without buffering, a feature useful for very big files. This xcopy option was first available in Windows 7.
|Use this option when copying read-only files to retain that file attribute in the destination.
|Use this option to show a list of the files and folders to be copied… but no copying is done. The /l option is useful if you’re building a complicated xcopy with several options and you’d like to see how it would function hypothetically.
|This option is identical to the /a option but the xcopy will turn off the archive attribute after copying the file. You can not use /m and /a together.
|This option creates files and folders in the destination using short file names. This option is only useful when you’re using the xcopy to copy files to a destination that exists on a drive formatted to an older file system like FAT which does not support long file names.
|Retains ownership and Access Control List (ACL) information in the files written in the destination.
|When using this option, you’ll be prompted before the creation of each file in the destination.
|A kind of the opposite of the /f option, the /q switch will put xcopy into “quiet” mode, skipping the on-screen display of each file being copied.
|Use this option to overwrite read-only files in the destination. If you don’t use this option when you want to overwrite a read-only file in the destination, you’ll be prompted with an “Access denied” message and the xcopy will stop running.
|Use this option to copy directories, subdirectories, and the files contained within them, in addition to the files in the root of the source. Empty folders will not be recreated.
|This option forces the xcopy to create a directory structure in the destination but not to copy any of the files. In other words, the folders and subfolders found in the source will be created but there we are no files. Empty folders will not be created.
|This option will only copy files in the source that are already in the destination.
|This option verifies each file as it’s written, based on its size, to make sure they’re identical. Verification was built into the xcopy beginning in Windows XP, so this option does nothing in later versions of Windows and is only included for compatibility with older MS-DOS files.
|Use the /w option to present a “Press any key when ready to being copying file(s)” message. The xcopy will begin copying files as instructed after you confirm with a key press. This option is not the same as the /p option which asks for verification before each file copy.
|This option copies file audit settings and System Access Control List (SACL) information. You imply /o when you use the /x option.
|Use this option to stop the xcopy from prompting you about overwriting files from sources that already exist in the destination.
|Use this option to force the xcopy to prompt you about overwriting files. This might seem like a strange option to exist since this is the default behavior of xcopy but the /y option may be preset in the COPYCMD environment variable on some computers, making this option necessary.
|This option allows the xcopy to safely stop copying files when a network connection is lost and then resume copying from where it left off once the connection is re-established. This option also shows the percentage copied for each file during the copy process.
|This option allows you to specify one or more file names containing a list of search strings you want the xcopy to use to determine files and/or folders to skip when copying.
|Use the help switch with the xcopy to show detailed help about the command. Executing xcopy /? is the same as using the help command to execute help xcopy.
The article was published on August 5, 2020 @ 5:31 AM