Moving and arranging files around on your computer can be time-consuming. In Windows 10, it is faster to create a batch file (.bat) and move multiple source files and subfolders to any destination folder. You can define the properties of such a .bat file in advance and transfer files later at your ease.
A .bat file is a well-known yet little used secret of Windows which can execute different kinds of commands with actionable results.
This is the latest 2020 guide for creating a batch file in Windows 10 from scratch. We will also show how to utilize such a .bat file to move files from any source to a destination folder.
Create a Batch File from Scratch
You can create a .bat file in any Windows 10 folder of your choice. To create it from scratch, simply go to the destination folder of your choice, right-click and create a new .txt file.
Once the Notepad file is created, rename the extension from .txt to .bat.
Ignore the “file will become unusable” message due to change in file name extension and click Yes. An empty batch file has now been created with no contents.
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.
Right-click the created .bat file to “Edit using Notepad” and enter the following to create folders using folder names.
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. Save the file and exit Notepad.
As soon as you 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. Save the file and exit Notepad.
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 10 to a destination folder of your choice. All you need is a proper folder path to complete the transfers. The best way to know a folder’s path is to right-click and select “Properties” followed by “Location.”
As shown here, we will move all the contents of “FolderA” to “FolderB.” The command is as follows:
*.* is a wildcard that tells Windows 10 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 clicking .bat file.
If you want to move only select files, the code can be slightly modified as shown below.
If you wish to move only specific file types between the folders, for example, JPG files, modify the code as shown below.
For example, to move all .jpg files, use the code below:
As per the code, only JPG files have moved in this example.
You can replace the .jpg with .pdf, .png, or any other file type you want to move.
In this guide you have learned how to create a batch file from scratch and move files and folders around your computer. Every time you click on a .bat file, it will move the contents at the target location. It’s so simple!