How to copy files using CMD commands in Windows – COPY, XCOPY and ROBOCOPY

0
64

CMD commands or ‘cmd.exe’ are command interpreters present in OS/2 and Windows NT operating systems (including Windows 2000, Windows Server 2003, Windows XP, Windows Vista, Windows 7, 8, 8.1, 10 and 11).

What types of commands exist to copy files from CMD in Windows?

Commands that are interpreted by CMD are useful for sending commands to the operating system; this allows you to organize files, open and start programs or execute any command that is related to the operating system, the computer or the network.

Copy

The COPY command is useful for copying one or more files into another specified folder; it is an internal command of ‘cmd.exe’. Its syntax is: COPY [/Y|/-Y] [/A|/B]source [/A|/B] [+ origen [/A|/B] [+…]][destino][/A|B][/V].

copy commands

  • Parameters:

    • Source: is the location where the file to be copied is located and its name. This can consist of the drive letter, a colon, and a directory name, a file name, or both.
    • Destination: shows the location where the files where the copies will be placed and the name they have are located. It can consist of the drive letter, a colon, and a directory name, a file name, or both.
  • Modifiers:

    • /Y: works as an indicator that you want COPY to replace existing files without asking for confirmation. Normally, COPY asks if you want to overwrite the existing file; this happens when an already existing file is specified as the destination file.
    • /-Y: works to indicate if you want COPY to ask for a confirmation when doing a replacement of an existing file.
    • /A: works to indicate an ASCII text file (code composed of characters from the Latin alphabet).
    • /B: works to indicate a binary file.
    • /V: works to verify that new files are written correctly.

xcopy

This command allows you to copy one or more files to a specific location. It differs from the COPY command because it can make copies of files and subdirectories. Its syntax is:

XCOPY source [destino] [/A | /M] [/D[:fecha]] [/P] [/S [/E]] [/V] [/W] [/C] [/I] [/Q] [/F] [/L] [/H] [/R] [/T] [/U] [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/EXCLUDE:archivo1[+archivo2][+archivo3]…]

xcopy commands

Each of the parameters contained in the command has a special function according to what the user needs:

  • Source: works to indicate the files to be copied.
  • Destination: Works to specify the new location and the new name of the files.
  • /A: works to copy only the files with the file attribute that has been set; thereby disabling the file attribute.
  • /D mda: Works to copy files that have been modified on or after the specified date. If no date is specified, only files with a source time more recent than the destination time are copied.
  • /EXCLUDE file1+file2 +file3: This indicates a list of files with string. It works when part of the file path matches any of the strings; if so, the file will be excluded from the copy.
  • /P: Works to request information before creating each target file.
  • /S: works to copy directories and subdirectories, except for those that are empty.
  • /E: works to copy directory and subdirectories; this time, including the empty ones.
  • /V: Works to check the integrity of each new file.
  • /W: Works to require a key to be pressed before copying.
  • /C: Works to continue copying, even if errors occur.
  • /L: if the destination does not exist and more than one file is copied, their destination will become a directory.
  • /Q: works so that file names are not displayed while copying.
  • /F: works to show the files that are going to be copied.
  • /H: Works to copy hidden files and system files.
  • /R: Works to overwrite read-only files.
  • /T: works to create directory structure; however, it does not copy files, and it does not include empty directories or subdirectories.
  • /T/E: Works to include empty directories and subdirectories.
  • /U: works to only copy existing files to the destination.
  • /K: works to copy attributes, it will reset read-only attributes.
  • /N: works to copy using the generated short names.
  • /O – Works to copy ACL information and members from files.
  • /X: works to copy the audit settings; this implies ‘/OR’.
  • /Y: works to suppress the confirmation message of overwriting an already existing destination file.
  • /-Y: Works to display a confirmation message if you want to overwrite an existing destination file.
  • /Z: Works to copy the network files in bootable mode.

robocopy

This type of command has the ability to withstand interruptions in the file copy process and indicates progress. To access it from Windows 10, open Windows Command Prompt or access Windows Powershell as administrator, when the command has been opened, the line ‘Robocopy’ should be executed. Thus, the description of this tool and its forms of use will be visible.

robocopy commands

How to copy folders with space in the name using CMD commands?

From CMD, you can copy folders that contain a space in their name by enclosing the full string path in quotes; otherwise the command will be interpreted as two separate strings.

path in quotes

What is the best way to copy files to USB using CMD?

With Robocopy you can copy the entire contents of a directory. You must run the command Robocopy C:UsersComputer D:Computer /e. the ‘/e’ switch works to include subfolders, even if they are empty. This command is useful when using USB because it copies folders completely.

Previous articleYou have it installed, and more than 20 antiviruses detect it as a virus: delete this NOW
Next articleMore than 1.1 million cars were sanctioned last year for having the ITV expired

LEAVE A REPLY

Please enter your comment!
Please enter your name here