How to Copy Files Using CMD Commands in Windows – COPY, XCOPY and ROBOCOPY

The CMD command or «cmd.exe» is the command interpreter present in OS/2, and Windows NT operating system (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 interpreted by CMD for Send commands to the operating system; This allows you to organize files, open and launch programs or execute any command related to the operating system, computer or network.

copy

The COPY command is useful for copying one or more files to Other specified folders; It is an internal command of «cmd.exe». Its syntax is: COPY [/Y|/-Y] [/A|/B]resource [/A|/B] [+ origen [/A|/B] [+…]][destino][/A|B][/V].

copy command

  • parameter:
    • Source: is the location of the file to be copied and its name. This can consist of a drive letter, colon and directory name, file name, or both.
    • Destination: Displays the location of the files where the copy will be placed and the name under which they are located. It can consist of a drive letter, a colon and a directory name, file name, or both.
  • modifier:
    • /Y: As an indicator that you want COPY to replace existing files without asking for confirmation. Normally, COPY will ask you if you want to overwrite an existing file; this happens when an already existing file is specified as the target file.
    • /-Y: Used to indicate whether you want COPY to ask for confirmation when replacing existing files.
    • /A: Used to indicate an ASCII text file (a code consisting of Latin alphabet characters).
    • /B: Used to represent binary files.
    • /V: Used to verify that the new file was written correctly.

copy

This command allows you to copy one or more files to a specific location.It is different from the COPY command because it does Can copy 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 command

Each parameter included in the command has a special function According to user needs:

  • Source: Used to indicate the file to copy.
  • destiny: for specifying a new location and the new name of the file.
  • /A: Copies only files for which file attributes have been set; thus disabling file attributes.
  • /D mda: Use to copy files modified on or after the specified date. If no date is specified, only files whose source time is later than the destination time are copied.
  • /EXCLUDE file1+file2 +file3: This represents a list of files with strings. It works when part of the file path matches any string; if so, the file is excluded from the copy.
  • /P: Request information before creating each object file.
  • /S: Suitable for copying directories and subdirectoriesexcept those that are empty.
  • /E: For copying directories and subdirectories; this time, including empty ones.
  • /V: Used to check the integrity of each new file.
  • /W: applies to A key needs to be pressed before copying.
  • /C: Continue copying even if an error occurs.
  • /L: If the destination does not exist and multiple files are copied, their destination becomes a directory.
  • /Q: Do not display filenames when copying while working.
  • /F: applies to Displays the files to be copied.
  • /H: For copying hidden and system files.
  • /R: Used to overwrite read-only files.
  • /T: Creates a directory structure; however, it does not copy files and does not include empty directories or subdirectories.
  • /T/E: Used to include empty directories and subdirectories.
  • /U: Only copies existing files to the destination.
  • /K: for copying propertieswhich resets the read-only property.
  • /N: Copy using the generated short name.
  • /O – Used to copy ACL information and members from a file.
  • /X: Used to copy audit settings; this means «/or».
  • /Y: Used to suppress confirmation messages for overwriting existing target files.
  • /-Y: A confirmation message can be displayed if an existing object file is to be overwritten.
  • /Z: applies to Copy network files in restartable mode.

machine copy

this type of command Ability to withstand disturbances During the process of copying files and indicate the progress. To access it from Windows 10, open a Windows Command Prompt or access Windows Powershell as an administrator, after opening the command, the «Robocopy» line should be executed. Therefore, a description of the tool and the form in which it is used will be visible.

robocopy command

How to copy folders with spaces in their names using CMD command?

In CMD, you can copy folders with spaces in their names by enclosing the full string path in quotes; otherwise the command will be interpreted as two separate strings.

path in quotes

What’s 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:\Users\Computer D:\Computer /e. The ‘/e’ switch can include subfolders even if they are empty. This command is useful when using USB because it copies the folder completely.

Deja un comentario