- How to copy a directory or folder
- Microsoft Windows
- MS-DOS and Windows command line
- Copy a directory and contents
- Copy the contents of a directory into another directory
- Copy a directory with a space in the name
- How to copy a directory to another drive
- Linux and Unix
- Windows copy command syntax and examples
- Copy the contents of a file to another file
- Copy file to another directory
- Copy files with white space in name
- Copy multiple files
- Use of environment variables
- How to Copy Files Using Command Prompt in Windows 7?
- Benefit from Command Prompt Copy Files
- How to Copy Files Using Command Prompt in Windows 7?
- Copy Specific File via Command Prompt
- Copy Directory and Contents Using Command Line
- Easier Way to Copy Files in Windows 7/8/10
- How to Copy Files/Folders in Windows 7 Step by Step?
- Summary
- copy copy
- Синтаксис Syntax
- Параметры Parameters
- Комментарии Remarks
- Примеры Examples
How to copy a directory or folder
Depending on your computer operating system, and where you want to execute the copy, there are several ways to copy a directory or folder. Select a link below for your operating system or where you want to perform the copy.
Microsoft Windows
To copy a folder in Microsoft Windows, follow the steps below. When copying a folder in Windows, everything in the folder, including all files and subdirectories are copied.
- Locate and highlight the folder you want to copy.
- How to select or highlight multiple files and folders.
- Right-click the folder and select Copy, or click Edit and then Copy.
- Move to the location you want to place the folder and all its contents, and right-click and select Paste, or click Edit and then Paste.
Once a file is copied, it can be pasted anywhere on the computer, including the desktop, another folder, or a drive.
You can also use the keyboard shortcuts to copy and paste files on the computer. For example, you could highlight any file and press Ctrl + C to copy the file. Once copied, you can move to where you want to paste the file and then press Ctrl + V to paste the file.
MS-DOS and Windows command line
To copy a directory in MS-DOS, use the xcopy command. Below is a basic example of each of the steps to do this in MS-DOS. If you need additional information about the xcopy command or additional examples, see the above xcopy command page.
By default, the basic xcopy command only copies files in the directory you specify as the source directory. You must use the /E option to copy subdirectories in the source directory as well.
Copy a directory and contents
In the example above, the directory «example» is copied into a new directory called «example2».
Copy the contents of a directory into another directory
- Move to the directory where you want to copy the directories and subdirectories. In the example below, we are moving to the temp2 directory using the cd command.
- Once in the directory, use the xcopy command to copy another directory’s subdirectories and contents. In the example below, we’re copying the «temp3» contents into the «temp2» directory. Keep in mind that this does not copy the actual directory «temp3». Only the files and subdirectories in the temp3 directory are copied.
Once the steps above are completed, everything should be copied into the temp2 folder.
Copy a directory with a space in the name
When dealing with a space in a file or directory, you always surround it with quotes.
In the example above, the directory «test» is copied into a new directory called «space test».
How to copy a directory to another drive
In the example above, the «test» directory on the C: drive would copy to the «test» directory on the D: drive.
Linux and Unix
To copy a directory with all subdirectories and files, use the cp command. Below is an example command of how you would use the cp command to copy files. Additional information about this command and other examples are available through the above cp link.
In the example above, the cp command would copy all files, directories, and subdirectories in the /home/hope/files directory to the /home/hope/backup directory.
Windows copy command syntax and examples
Using copy command, we can copy files from one directory to another directory. This command is similar to the Linux cp command, but it does not match with the full functionality of cp. Windows copy command can be used to copy files only, we can’t copy directories.
The syntax and usecases of copy command are explained below with examples.
Copy the contents of a file to another file
Example: To copy a file from c:\data\file1.doc to D:\backup\file2.doc
If the destination file already exists you will be prompted for confirmation. To suppress this confirmation you can use /Y switch with copy command. This would be useful if you are executing copy command from a batch file.
If the destination file exists, the above command will overwrite the same without asking the user for confirmation.
Copy file to another directory
When we specify a directory path as the destination, the files will be copied with the same name. We can assign a different name by specifying the new name in the destination path. Example is shown below.
To copy the file 1.doc loated at c:\data\documents to the directory c:\data\newdocs
Copy files with white space in name
If the file name has white space within it, we can wrap up the name in double quotes.
Example: To copy file, my resume.doc to another folder
Copy multiple files
We can’t specify multiple file names in copy command. However, we can use wildcards to identify a group of files and then copy all of them in a single command.
For example, to copy all excel files from current folder to another folder F:\backup
To copy all files in current folder to another folder
Use of environment variables
We can use environment variables in the copy command to specify the path of the folders. Like USERPROFILE, SystemRoot, ProgramFiles, TEMP, WINDIR, APPDATA, HOMEPATH.
For example, to copy a file to a user’s documents folder
The above command copies the file to the My Documents folder of the current logged in user.
You may also want to read
Windows «copy» is funny. Type «copy 1 2» and the file «1» will be copied into a new file «2». Now separate them by a plus sign instead of a space (copy 1+2) and you’ll concatenate 1 and 2 and replace the old file «1» with the result of the concatenation!
Yes, we can concatenate two or more files using copy command. You need to separate the list of files using +. You can redirect the resultant data to a new file also.
The above command will not alter the file 1. It creates a new file 3 with the concatenated data of 1 & 2. If no file name is provided it stores the result in the first file.
My Win7 cannot find a copy command, and when i run xcopy, a window flashes and exits.
I have the same problem. If you solved it, could you please explain how?
If you can not find your copy.exe file, you can download it to your windows directory or C:\ Directory depending the setting on your OS you should also be able to copy and run it from system32 or system folder.
how can i combine 2 .exe files and be able to use both after concatenation
I want to copy 2 different files(.exe,.config) from source to destination server of windows.
can you please help me on this command.
Hello i have a problem with my cmd windows 7.when i try to copy a command. Like help > file.pdf. i mean in extension pdf because i have this problem only with .pdf extension but not with .txt.So whe i execute the command. No problem. Then when i go to open the file.pdf ftom user destination the file.pdf doesn’t open say that is corrupted.please do help me .thanks
i have a file contain many lines as sources and another file has the same numbre of lines as destinations. i want to copy first line as source( c:/test/*.txt) to first line in destination ( d:/test2/), secend line ( c:/test/*.pdf) to second line in destination ( E:/test3/)……
Can I use the DOS/Windows “COPY” command in a BAT file to copy a file or a short string of text to computer memory and then paste (Ctrl +V) that string or file into a document?
How to Copy Files Using Command Prompt in Windows 7?
This article tells how to copy files using Command Prompt in Windows 7 with simple steps. Also, another powerful tool to copy files in Windows 7/8/10 will be introduced.
By Teresa / Last Updated January 5, 2021
Benefit from Command Prompt Copy Files
Copying files with command line has some advantages comparing to traditional way of files copying. For example, it saves the time of manually copy and paste. Also, it supports unattended task while copying. That is to say, you can leave the computer alone and take a break after inputting some certain commands. The task will run automatically.
Unlike some sorts of data backup with CMD, it is a little bit of fiddly to copy each file manually, especially when these files are stored in different locations. If they are placed in one same partition or volume, it would be more convenient to backup entire partition.
Anyway, you may have other reasons to do files copy in Command Prompt. However, the most important thing is to figure out how to perform.
How to Copy Files Using Command Prompt in Windows 7?
Two methods on how to copy and paste files using CMD for different purposes will be introduced below. Choose the one that suits you most.
Copy Specific File via Command Prompt
1. Press Windows + R key combination (or click Start) to start Run.
2. Type cmd and hit OK in the box to launch Command Prompt.
3. At the prompt, type copy c:\workfile.txt d: and press Enter to copy the file named “workfile.txt” on the root of C drive to D drive root.
Tips:
To copy some certain file extensions from one drive to another, you can run, for example, copy *.txt d: to copy all texts to D drive at a time.
This method also applies to copying files using Command Prompt in Windows 10.
Copy Directory and Contents Using Command Line
It would be better to copy folders with the help of XCopy command in this method.
1. Open a Command Prompt as instructed.
2. Input xcopy c:\workfile d:\test and press Enter to copy a directory and contents in “workfile” to “test”.
3. To copy a directory with a space in the name, you need to surround it with quotes. For example, type xcopy c:\workfile “d:\test new”.
Tips: By default, the basic XCopy command only copies files in the directory you specify as the source directory. You must use the /E option to copy subdirectories within the source directory as well.
Easier Way to Copy Files in Windows 7/8/10
With covered two methods, it is quite easy to copy files in Windows 7 with command line. Nevertheless, those methods are convenient for some special groups of Windows users who are familiar with command line operations. For the majority of users, that is a little complex. In addition, the XCopy command refuses to work sometimes. That’s why so many people looking for XCopy alternative on the Internet.
Is there simpler way to copy files from one location to another in Windows 7? Apparently, the answer is positive. AOMEI Backupper Professional is reliable backup software that designs for Windows OS only. It allows you to backup files to different places as well as sync files/folders in Daily, Weekly, Monthly, Event-trigger and Real-time mode. Full backup, incremental backup and differential backup are also supported.
For advanced users, the software also provides the way to backup hard disk, system drive, and partition/volume in Command Prompt. You can also do system restore from Command Prompt when the need ever arises in the future. Except for that, command line clone hard drive, partition, or system drive is also available.
How to Copy Files/Folders in Windows 7 Step by Step?
1. Download AOMEI Backupper, install and start it. Connect the external storage to your Windows 7 if necessary.
2. Click Sync and select Basic Sync.
3. Choose the files or folders you’d like to copy from by clicking Add Folder.
4. Choose the destination path you’d like to copy to. You are allowed to copy files to OneDrive.
5. Click Start Sync to execute the task.
Tips:
Options: comment the task and set email notification here. You’ll see encrypt backup image, split image and compress image in this option if you run backup task.
Schedule: choose synchronization schedule type from Daily, Weekly, Monthly, Event triggers and USB plug in here.
The program will run missed task at the next system startup by default.
You can add multiple folders and to do synchronize them at a time.
Edit the task name if you want to.
Summary
Two available ways on how to copy files using Command Prompt in Windows 7 are presented in this article. Choose the most helpful one based on your situation. What’s more, another way on how to easily copy files in Windows 7/8/10 is also been discussed. The comprehensive backup software supports move hard drive to new computer in Windows 7 as well.
If you want to protect unlimited computers within your company, you can pick AOMEI Backupper Technician. With the inbuilt AOMEI Image Deploy tool, you are also allowed to deploy/restore system image file on server-side computer to multiple client-side computers over network.
copy copy
Копирует один или несколько файлов из одного расположения в другое. Copies one or more files from one location to another.
В консоли восстановления можно также использовать команду Копировать с другими параметрами. You can also use the copy command, with different parameters, from the Recovery Console. Дополнительные сведения о консоли восстановления см. в разделе Среда восстановления Windows (Windows RE). For more information about the recovery console, see Windows Recovery Environment (Windows RE).
Синтаксис Syntax
Параметры Parameters
Параметр Parameter | Описание Description |
---|---|
/d /d | Позволяет сохранить копируемые зашифрованные файлы в виде расшифрованных файлов в месте назначения. Allows the encrypted files being copied to be saved as decrypted files at the destination. |
/v /v | Проверяет, правильно ли записаны новые файлы. Verifies that new files are written correctly. |
/n /n | Использует короткое имя файла (если доступно) при копировании файла с именем длиннее восьми символов или с расширением имени файла длиннее трех символов. Uses a short file name, if available, when copying a file with a name longer than eight characters, or with a file name extension longer than three characters. |
/y /y | Подавляет запрос на подтверждение перезаписи существующего целевого файла. Suppresses prompting to confirm that you want to overwrite an existing destination file. |
/-и /-y | Выводит запрос на подтверждение перезаписи существующего целевого файла. Prompts you to confirm that you want to overwrite an existing destination file. |
/z /z | Копирует сетевые файлы в перезапускаемый режим. Copies networked files in restartable mode. |
/a /a | Указывает текстовый файл ASCII. Indicates an ASCII text file. |
/b /b | Указывает на двоичный файл. Indicates a binary file. |
Обязательный элемент. Required. Указывает расположение, из которого необходимо скопировать файл или набор файлов. Specifies the location from which you want to copy a file or set of files. Источник может состоять из буквы диска и двоеточия, имени каталога, имени файла или их сочетания. Source can consist of a drive letter and colon, a directory name, a file name, or a combination of these. | |
Обязательный элемент. Required. Указывает расположение, в которое необходимо скопировать файл или набор файлов. Specifies the location to which you want to copy a file or set of files. Назначение может состоять из буквы диска и двоеточия, имени каталога, имени файла или их сочетания. Destination can consist of a drive letter and colon, a directory name, a file name, or a combination of these. | |
/? /? | Отображение справки в командной строке. Displays help at the command prompt. |
Комментарии Remarks
Можно скопировать текстовый файл ASCII, в котором используется символ конца файла (CTRL + Z), чтобы указать конец файла. You can copy an ASCII text file that uses an end-of-file character (CTRL+Z) to indicate the end of the file.
Если параметр /a предшествует или следует за списком файлов в командной строке, он применяется ко всем файлам, перечисленным до тех пор, пока не встретится копия . If /a precedes or follows a list of files on the command line, it applies to all files listed until copy encounters /b. В этом случае /b применяется к файлу, предшествующему /b. In this case, /b applies to the file preceding /b.
Действие /a зависит от его расположения в строке командной строки: The effect of /a depends on its position in the command-line string: — Если после Source указано значение /a , команда Copy обрабатывает файл как ASCII-файл и копирует данные, предшествующие первому символу конца файла (Ctrl + Z). If /a follows source, the copy command treats the file as an ASCII file and copies data that precedes the first end-of-file character (CTRL+Z). — Если параметр /a следует за назначением, команда Copy добавляет символ конца файла (Ctrl + Z) в качестве последнего символа файла. If /a follows destination, the copy command adds an end-of-file character (CTRL+Z) as the last character of the file.
Если /b указывает интерпретатору команд считывать число байтов, указанное размером файла в каталоге. If /b directs the command interpreter to read the number of bytes specified by the file size in the directory. /b — это значение по умолчанию для Copy, если только копирование не объединяет файлы. /b is the default value for copy, unless copy combines files.
Если /b предшествует или следует за списком файлов в командной строке, он применяется ко всем файлам в списке до тех пор , пока не встретится параметр /a. If /b precedes or follows a list of files on the command line, it applies to all listed files until copy encounters /a. В этом случае /a применяется к файлу, предшествующему /a. In this case, /a applies to the file preceding /a.
Действие /b зависит от его позиции в командной строке:-if /b следует за источником, команда Copy копирует весь файл, включая любой символ конца файла (Ctrl + Z). The effect of /b depends on its position in the command–line string: — If /b follows source, the copy command copies the entire file, including any end-of-file character (CTRL+Z). -If /b следует за назначением, команда Copy не добавляет символ конца файла (Ctrl + Z). — If /b follows destination, the copy command doesn’t add an end-of-file character (CTRL+Z).
Если операция записи не может быть проверена, появляется сообщение об ошибке. If a write operation cannot be verified, an error message appears. Хотя ошибки записи редко возникают с помощью команды Copy , можно использовать /v для проверки правильности записи важных данных. Although recording errors rarely occur with the copy command , you can use /v to verify that critical data has been correctly recorded. Параметр командной строки /v также замедляет команду Copy , так как необходимо проверить каждый сектор, записанный на диске. The /v command-line option also slows down the copy command, because each sector recorded on the disk must be checked.
Если в переменной среды копикмд предустановлен параметр /y , его можно переопределить с помощью /-и в командной строке. If /y is preset in the COPYCMD environment variable, you can override this setting by using /-y at the command line. По умолчанию при замене этого параметра выводится запрос, если команда Copy не выполняется в пакетном скрипте. By default, you are prompted when you replace this setting, unless the copy command is executed in a batch script.
Чтобы добавить файлы, укажите один файл для назначения, но несколько файлов для источника (используйте символы-шаблоны или формат файла file1 + file2 + файл3 ). To append files, specify a single file for destination, but multiple files for source (use wildcard characters or file1+file2+file3 format).
Если во время фазы копирования теряется соединение (например, если сервер переходит в автономный режим), можно использовать копию/z , чтобы возобновить подключение после восстановления подключения. If the connection is lost during the copy phase (for example, if the server going offline breaks the connection), you can use copy /z to resume after the connection is re-established. Параметр /z также отображает процент завершения операции копирования для каждого файла. The /z option also displays the percentage of the copy operation that is completed for each file.
Имя устройства можно заменить одним или несколькими экземплярами источника или назначения. You can substitute a device name for one or more occurrences of source or destination.
Если назначением является устройство (например, COM1 или LPT1), параметр /b копирует данные на устройство в двоичном режиме. If destination is a device (for example, Com1 or Lpt1), the /b option copies data to the device in binary mode. В двоичном режиме copy/b копирует все символы (включая такие специальные символы, как CTRL + C, CTRL + S, CTRL + Z и ввод) на устройство в виде данных. In binary mode, copy /b copies all characters (including special characters such as CTRL+C, CTRL+S, CTRL+Z, and ENTER) to the device, as data. Однако если параметр /b не указан, данные копируются на устройство в режиме ASCII. However, if you omit /b, the data is copied to the device in ASCII mode. В режиме ASCII специальные символы могут привести к объединению файлов во время процесса копирования. In ASCII mode, special characters might cause files to combine during the copying process.
Если целевой файл не указан, создается копия с тем же именем, датой изменения и временем изменения, что и в исходном файле. If you don’t specify a destination file, a copy is created with the same name, modified date, and modified time as the original file. Новая копия хранится в текущем каталоге на текущем диске. The new copy is stored in the current directory on the current drive. Если исходный файл находится на текущем диске и в текущем каталоге, и не указан другой диск или каталог для целевого файла, команда Copy остановится и отобразится следующее сообщение об ошибке: If the source file is on the current drive and in the current directory and you do not specify a different drive or directory for the destination file, the copy command stops and displays the following error message:
Если в источнике указано несколько файлов, команда Copy объединяет их в один файл, используя имя файла, указанное в поле назначение. If you specify more than one file in source, the copy command combines them all into a single file using the file name specified in destination. Команда Copy предполагает, что Объединенные файлы являются файлами ASCII, если не используется параметр /b . The copy command assumes the combined files are ASCII files unless you use the /b option.
Чтобы скопировать файлы длиной 0 байт или скопировать все файлы и подкаталоги каталога, используйте команду xcopy. To copy files that are 0 bytes long, or to copy all of a directory’s files and subdirectories, use the xcopy command.
Чтобы назначить текущее время и дату файлу без изменения файла, используйте следующий синтаксис: To assign the current time and date to a file without modifying the file, use the following syntax:
Где запятые указывают, что конечный параметр был намеренно оставлен. Where the commas indicate that the destination parameter has been intentionally left out.
Примеры Examples
Чтобы скопировать файл с именем memo.doc для letter.doc на текущем диске и убедиться, что символ конца файла (Ctrl + Z) находится в конце скопированного файла, введите: To copy a file called memo.doc to letter.doc in the current drive and ensure that an end-of-file character (CTRL+Z) is at the end of the copied file, type:
Чтобы скопировать файл с именем перебора. Typ из текущего диска и каталога в существующий каталог с именем птиц , расположенный на диске C, введите: To copy a file named robin.typ from the current drive and directory to an existing directory named Birds that is located on drive C, type:
Если каталог птиц не существует, файл Renamed . Typ копируется в файл с именем птиц , расположенный в корневом каталоге на диске C. If the Birds directory doesn’t exist, the file robin.typ is copied into a file named Birds that is located in the root directory on the disk in drive C.
Чтобы объединить Mar89. rpt, Apr89. rpt и May89. rpt, расположенные в текущем каталоге, и поместить их в файл с именем Report (также в текущем каталоге), введите: To combine Mar89.rpt, Apr89.rpt, and May89.rpt, which are located in the current directory, and place them in a file named Report (also in the current directory), type:
При объединении файлов команда копирования помечает конечный файл текущими датой и временем. If you combine files, the copy command marks the destination file with the current date and time. Если параметр Destination не указан, файлы объединяются и сохраняются под именем первого файла в списке. If you omit destination, the files are combined and stored under the name of the first file in the list.
Чтобы объединить все файлы в отчете, если файл с именем Report уже существует, введите: To combine all files in Report, when a file named Report already exists, type:
Чтобы объединить все файлы в текущем каталоге, имеющие расширение txt, в один файл с именем Combined.doc, введите: To combine all files in the current directory that have the .txt file name extension into a single file named Combined.doc, type:
Чтобы объединить несколько двоичных файлов в один файл, используйте подстановочные знаки, включите /b. To combine several binary files into one file by using wildcard characters, include /b. Это предотвращает расинтерпретацию CTRL + Z в качестве символа конца файла в Windows. This prevents Windows from treating CTRL+Z as an end-of-file character. Например, введите: For example, type:
При объединении двоичных файлов результирующий файл может оказаться непригодным для использования из-за внутреннего форматирования. If you combine binary files, the resulting file might be unusable due to internal formatting.