How To Copy A File In Bat

Table of contents:

How To Copy A File In Bat
How To Copy A File In Bat

Video: How To Copy A File In Bat

Video: How To Copy A File In Bat
Video: Batch Programing: Lesson 4 (How to Copy,Move and Rename files + MORE) 2024, December
Anonim

The bat file contains a set of DOS commands that are designed to be executed by a specialized interpreter program from the operating system. Despite the fairly perfect graphical interface of modern operating systems, some tasks are easier to solve using such rudimentary remnants of the heyday of the command line interface.

How to copy a file in Bat
How to copy a file in Bat

Necessary

Text editor

Instructions

Step 1

To create bat files, no special software is required, since the format of the data they contain is no different from ordinary txt files. Open any text editor - Word, WordPad, Notepad, etc. will do.

Step 2

On the first line of a new document, type the command copy - copy. Then put a space and enter the full address of the file you want to duplicate. On Windows, it must start with a drive letter and contain a backslash-separated set of all folders in the path from the root directory to the directory in which the file is located. For example, this entry might look like this: F: sourcesRelMedia mpsomeFile.txt.

Step 3

Put another space and, according to exactly the same rules, enter the full path and name of the duplicate file into which you want to copy the original object. The entire line with the copy command may look like this: copy F: sourcesRelMedia mpsomeFile.txt H: ackUpssomeFileCopy.txt

Step 4

The copy command can, during copying, combine the contents of several sources and write the result to one common file. To take advantage of this feature, list all the source objects to be merged, separated by a plus surrounded by spaces. Specify the name of the copy file in the same way as in the previous step. An example of such a command, combining the contents of three text files: copy F: someFile1.txt + F: someFile2.txt + F: someFile3.txt H: someFileCopy.txt

Step 5

If you need to copy the entire contents of a directory, including its subfolders, use another command - xcopy. It also requires specifying two full addresses - the source folder and the destination folder. Instead of the names of the copied files, use "wildcard": *. *. For example: copy F: sourcesRelMedia mp *. * H: ackUps *. *

Step 6

Save the file with the desired name and always with the bat extension.

Recommended: