
Moving and arranging files on your computer can take a long time. In Windows, it is quicker to make a batch file (.bat) and move a lot of source files and subfolders to any folder. A .bat file can be made in advance and then you can transfer files at your own speed.
In this tutorial, we’re gonna create a batch script for Windows 11 and 10 to move files from one source to another destination folder.
What Batch Files Do in Windows?
Windows can run .bat files, Which can be used to automate things and execute different kinds of commands with a batch script. Using a batch file, you can set it up so that it runs at a certain time in the background.
Create a Simple Batch File in Windows
We’re gonna create a simple batch file in Windows.
- Open a text file, like a Notepad or WordPad document.
- Type something in the text box.
- When you save your file, give it the file extension BAT, such as sample.bat.
- Double-click the BAT file you just made to run your batch file.
This is our sample output after running the batch script.
Create Folders and Subfolders Using Batch Script
Using the .bat script you can create folders and subfolders that are linked to the .bat file. No matter where you move the .bat file on your computer, all of the folders and subfolders will move with it as well. Any files that have been saved in these folders can be moved easily by moving the script .bat file.
Create a root folder in which all other folders will appear. Create a text file in the root folder and run the md command as follows.
First, open your code editor or you can simply use notepad and type:
@echo off md Folder1 Folder2 "Folder5"
To create new folders, double click the.bat file.
To make subfolders in any folder, change the above code as shown here by adding the names of the subfolders after the folder name.
@echo off md "Folder1"/SubFolder1 "Folder2"/SubFolder2
The subfolders have been created.
Move Files Using Batch Files
Files can be moved from one folder to another using.bat file. To find a folder’s path, right-click and select “Properties”, then “Location”. Copy and paste the location into the bat.
The “move” command is used to move files in a folder.
As shown, we are relocating “Folder A” to “Folder B” The command is:
move Source-Path*.* Destination-Path
Double-clicking the.bat file moved the content of one folder to another. To move only selected files, add the file name before the *.* as shown below.
move C:\Users\Noor\Desktop\"New folder"\FileNameHere*.* C:\Users\Noor\Desktop\"New folder"\Folder1
If you just want to move certain file types between directories, like .pdf files, change the code by adding the file type ahead of *.*.
move C:\Users\Noor\Desktop\"New folder"\*.file_type*.* C:\Users\Noor\Desktop\"New folder"\Folder1