Write your first .bat file

A script file or file.Beat contains a series of DOS commands, and is typically written to automate frequently-run tasks. Instead of typing the same commands again and again, you can simply double-click the batch file. Writing a batch file is much easier than you imagine. windows tools bat bat

The hard part is to make sure everything is done in the right order. A well-written script can save you a lot of time in the long run, especially it is often used in repetitive tasks.


Open Notepad or notepad. The notebook allows you to write the code as a text file, and then save it as a batch file.
You can open the Notepad by clicking Start / Programs / Utilities / Notepad, or by right-clicking on the New / Text desktop.

Basic commands

Batch files perform a series of DOS commands, and the commands you can use are similar to DOS commands. Some of the most important are:

ECHO - displays the text on the screen
ECHO OFF - Hides the text
START - Execute a file
REM - To write a line of explanations in your program
MKDIR / RMDIR - Create and remove folders
OF - Deletes a file or files
COPY - Copy a file or files
XCOPY - Allows you to copy files with additional options
FOR / IN / DO - This command allows you to specify files.
TITLE - Edit the title

One of the easiest ways to learn to write bundle files is to focus on basics first. For example, you can use a batch file to quickly create a folder:

MKDIR C: \ example

Save the file. Once you've written the above code, you can save the file as txt. Then, turn off the .txt suffix and name the text file with the .bat or .cmd extension. If you are running the file you created, it will make a folder in C: \ with the example name.
Make sure the encoding is ANSI before saving the file

This way you can write a basic backup program. Batch files can execute too many commands, but today we will deal with the basics.

With the XCOPY command, you can create a batch file that copies files from selected folders to a backup folder, replacing only the files that have been updated since the last backup:

Let's say you want to copy the test folder from C: \ into the iguru.gr folder. The command you will write in notepad will be like this:

ECHO OFF XCOPY c: \ test c: \ iguru.gr / m / e / y

The command as mentioned above copies the files from the "test" folder to the "iguru.gr" folder. You can replace the folder names we use with the paths to the folders you want. / M specifies that only updated files will be copied, / e specifies that all folders in the test folder will be copied and PC will give you a confirmation message each time a file is replaced.

Save the file. Once you've written the above code, you can save the file as txt. Then, turn off the .txt suffix and name the text file with the .bat or .cmd extension. You can try to run it.

We give you some ready-made files that may be useful to you.

Open Microsoft Word

@echo off start / d "C: \ Program Files \ Microsoft Word" WINWORD.EXE

(Change the path with your Office installed folder)

Make a list of the programs you have within Program Files

@echo off dir "C: \ Program Files"> C: \ list_of_program_files.txt

Read them Technology News from all over the world, with the validity of iGuRu.gr

Follow us on Google News iGuRu.gr at Google news