A .bat file is a well-known yet little used secret of Windows that can execute different kinds of commands with actionable results. This is the latest guide for creating a batch file in Windows 11 and 10 from scratch. We also show how to utilize such a .bat file to move files from any source to a destination folder.

What Do Batch Files Do in Windows?

A batch file in Windows is an automated script file that helps perform routine tasks using predefined commands without any further user action. With a batch file, you can set it to run automatically at a predefined hour in the background.

Create a Batch File from Scratch

You can create a .bat file in any Windows folder of your choice. To create it from scratch, simply go to the destination folder of your choice. The .bat file is prominently visible in the folder. It can be deleted, copy-pasted, renamed, and transferred to any other folder.

Use Batch File to Create Folders and Subfolders

You can use a .bat file to create separate folders and subfolders whose contents and properties remain connected to the .bat file. No matter which PC location you move the .bat file to, the folders and subfolders will follow. Any contents saved in these folders can simply be moved by relocating the Master .bat file. There are two ways to operate a .bat file with Notepad. In the first method shown below, open Notepad in Administrator mode from the Start menu. Open the .bat file in Notepad from its saved folder location, and its contents will be populated. Another direct way to work with a .bat file is to right-click the created .bat file, which allows you to “Edit using Notepad.” In Windows 10, it can be accessed directly with a right-click. In Windows 11, you have to click “Show more options” to see the Notepad option among other programs. Once the Notepad file is opened, enter the following to create folders using folder names, then save the file and exit Notepad. The purpose of @echo off is to disable the display prompt. This way you won’t have to deal with the Command prompt, although it’s internally connected to .bat file processes. If your folder name should contain a space, put it inside quotes. As soon as you double-click the .bat file, it will execute the command to create the new folders. To create subfolders in any folder, modify the above code as shown here by mentioning the subfolder names after the folder name. Save the file and exit Notepad, then double-click the .bat file again. As shown here, the subfolders have been created.

Move Files From One Folder to Another Using Batch Files

You can use .bat files to move files from any folder on your Windows PC to a destination folder of your choice. All you need is a proper folder path to complete the transfers in a bulk folder move. The best way to know a folder’s path is to right-click and select “Properties” followed by “Location.” Copy-paste the location entirely into the bat. file. To batch move files in a folder, we are using the “move” command. As shown here, we are moving all the contents of “Folder A” to “Folder B.” The command is as follows: Here, . is a wildcard that tells Windows to copy all the files in the source folder. If any part of the folder path has a folder name with spaces, you need to enclose it within quotes. Save the file and exit Notepad. The entire contents of one folder have been moved to another by double-clicking the .bat file. If you want to move only select files, the code can be slightly modified by putting the file name ahead of . as shown below. If you wish to move only specific file types between the folders, for example, .png files, modify the code by putting the filetype ahead of . as shown below. For example, to move all image files with .png extension, use the code below: As per the code, only .png files have been moved in this example. You can replace the .png in the above example with .jpg, .pdf, .doc, .ppt, or any other file type you want to move.

1. Can I use a batch file to rename multiple files?

Yes, you can, but a batch file isn’t necessary, as there are simpler ways to batch rename files in Windows.

2. Can batch files be dangerous?

Not all batch (.bat) files are dangerous. The ones you create don’t harm your system, as they run a legitimate script. However, malware authors often use known Windows processes to infect healthy systems. Batch files execute a series of commands that cannot be stopped once the files have been double-clicked. This makes them a popular means to infect Windows systems. Most malicious .bat files, however, will not be allowed to download on your PC provided you haven’t disabled the SmartScreen filter. When a malicious batch file does creep into your Downloads folder, Windows Defender will automatically alert you. If the .bat script is programmed to run on a double-click, it will be quarantined by Windows Defender.

3. Can I run a batch file as a startup program?

Yes. You can easily program a batch file to run each time Windows boots up. First, create a shortcut for the .bat file using a right-click. This shortcut can be saved on the desktop or anywhere else that’s convenient. Paste the shortcut into the Windows Startup folder found at “C:\Users\Username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.” You can also use the same Startup folder to remove the batch file from the startup programs list.