Create batch file: A Guide

With the Windows text editor and DOS commands you have already everything that is needed to create a batch file (.bat). Batch files allow you tasks that are performed on a regular basis to automatically perform. Instead of repeatedly entering the same commands, then simply click on the batch file. You can read how such files are created.

Create batch file

In fact, writing a batch file is not as hard as it may seem at first glance. It is important that the DOS commands are respectively written in a line and properly positioned. If you double click on the little self-created program to be executed in that order.

Create batch file: An Introduction

To create a batch file that needs its DOS commands. A list of commands is displayed to you if you call the CMD command line and run the command &# 8220; help&# 8221; eingebt. A list of all processes running on your computer, you can also get here by the way with the command &# 8220; taskList&# 8221 ;.

The tricky am writing a batch file is to arrange the right commands in the right order. If this fails, it can quickly lead to dysfunctions on your computer. So if you have an older second computer could try without risk, whether the created batch file also fulfills its purpose at this first.

Create batch file

The most important commands, with which you can create a batch file:

ECHODisplays text on the screen.
@ECHO OFFHides the text actually displayed.
BEGINStarts a file in its default application.
REMAdds a comment line in the program.
MKDIR / RMDIRCreated or removed folder.
DELDeletes one or more files.
COPYCopies one or more files.
XCOPYAllows copying files with additional options.
FOR / IN / DOThese commands you can select specific files.
Start Photogallery(10 images)Which motherboard I have? find out the motherboard!

Create batch file: An example for beginners

In order to understand the operation of batch files, it's best to start with simple examples. Here we show how you can create a back-up routine are automatically copied in the files to a specified backup folder:

  • Opens the text editor, either by right-clicking the Start menu -> run -> Text editor (Notepad) or by right clicking on the desktop -> New -> Text file.
  • The text editor opens and here you give now, line by line, the commands.
  • In our example, the two lines are: @ECHO OFF and XCOPY c: \ original c: \ backup / m / d / y
Create batch fileCreate a batch file in a text editor. Important: Before saving &# 8220; All files&# 8221; Select and use the .bat extension.
  • This command displays all files in a folder (Original) are now copied to the folder backup. / M sets is that it only updated files are copied, e / indicates that copies all subfolders of the respective directory and / y it determines that a confirmation message is displayed when overwriting old files.
  • When you save the file you can as usual &# 8220; Save&# 8221; work, you have to just be careful that you do not rename the file as a .txt, but as .bat and stores. To do this you presents &# 8220; All files&# 8221; and sets behind the filename .bat a point and the ending.
  • Advanced: With the program Bat to Exe Converter you can convert your quickly in .exe files self-written batch files!

The whole again as a video tutorial to watch, listen and imitate:

Did you "Create batch file: A Guide" fallen from Kristina Kielblock?Write us in the comments or share the article.We look forward to your opinion - and of course you must like us on Facebook,twitter or Google+.

14.11.2017

Posted In: software

map