Skip to content

COPY command

FireBlade edited this page May 8, 2026 · 2 revisions

Copies a file from one location to another.

Usage

copy <SRC> <TARGET> [options]

Arguments

  • <SRC>
    The source file(s) to copy. Can specify multiple files. Each file must be separated by a pipe character (|).
  • <TARGET>
    The target location(s) to copy to. Can specify multiple files only if the /M option is specified. Each file must be seperated by a pipe character (|).

Options

Note

The annotations 🪟 and 🐧 indicate that an option is only available on either Windows or Linux, respectively.

  • -u (--preserve-undo, /U) 🪟
    Preserve undo information, if possible.

  • -o (--files-only, /O) 🪟
    Perform the operation only on files (not on folders) if a wildcard file name (*) is specified.

  • -m (--multi-dest, /M)
    The TARGET argument specifies multiple destination files (one for each source file in SRC) rather than one directory where all source files are to be copied to. The target files must be separated by a pipe character (|).

  • -c (--no-connections, /C) 🪟
    Do not copy connected files. Only copy the specified files. For more info, see the Remarks section below.

  • -s (--no-copy-security, /S) 🪟
    Do not copy the security attributes of the file. The destination file receives the security attributes of its new folder.

  • -r (--recursive, /R) 🪟
    Recursively operate into subdirectories.

  • -e (--rename-on-collision, /E) 🪟
    Give the file being operated on a new name in a copy operation if a file with the target name already exists at the destination.

  • -v (--overwrite, /V) 🐧
    Overwrite the file if it already exists at the destination.

  • /? (/h, -h, --help)
    Show help and usage information.

Aliases

cp, cpy

Remarks

The COPY command copies one or more files or directories to a target location.

To copy multiple files or directories, specify the /M flag and separate the files or directories with a pipe (|) character.


Note

The section below applies only to Windows.

Prior to Windows Vista, operations could be undone only from the same process that performed the original operation.

In Windows Vista and later systems, the scope of the undo is a user session. Any process running in the user session can undo another operation. The undo state is held in the Explorer.exe process, and as long as that process is running, it can coordinate the undo functions.

If the source file parameter does not contain fully qualified path and file names, the /U option is ignored.

The /S option causes the command to not copy the ACL (Access Control List) of the original file. Instead, the destination file(s) receive the ACL of the destination folder.

Since Windows 2000, a HTML file can be connected to its associated files, and the files will be copied together (unless the /C option is specified).

To create a group of connected files, the primary document must have an .htm or .html file name extension. Create a subfolder of the primary document's parent folder. The subfolder's name must be the name of the primary document, minus the .htm or .html extension, followed by one of the extensions listed below. The most commonly used extensions are .files or _files. For instance, if the primary document is named MyDoc.htm, naming the subfolder MyDoc_files defines the subfolder as the container for the document's connected files. If the primary document is moved or copied, the subfolder and its files are moved or copied as well.

For some languages, it is possible to use a localized equivalent of _files to create a subfolder for connected files. The following table lists the valid strings that can be appended to a document name to create a connected files subfolder. Note that some of these strings have - as their first character rather than _ or ..

_archivos _arquivos _bestanden _bylos -Dateien _datoteke
_dosyalar _elemei _failid _fails _fajlovi _ficheiros
_fichiers -filer .files _files _file _fitxers
_pliki _soubory _tiedostot

For more information, see Connected Files.

Clone this wiki locally