It is key for users to be able to move and rearrange their files, especially if they use Windows for professional purposes. Moving files one by one can be a tedious process, in which case creating a batch file (.bat) and encapsulating all the files you want to move inside it, can be of help. In this tutorial, we will look at how you can create a batch file on Windows 11/10 and use it to move files.
Create and Use a Batch File to Move Multiple Files in Windows 11/10
A Batch file is a script file that helps in automating periodic tasks with the help of commands. Let us now look at the steps you need to follow to create a batch file.
How to create a Batch file on Windows 11/10
There are no restrictions in terms of the destination directory or folder to keep your Batch file in. Simply open File Explorer, visit the desired location and proceed with the steps of creating the file.
- While in the desired folder, right-click on the space and hover your cursor over the ‘New’ option
- Here, select to create a ‘.txt’ document
- Rename this document to a name of your choice and change its file extension from .txt to .bat
- Ignore the ‘this file may become unusable’ prompt and proceed with the process
You’ll now notice a new .bat file in the directory with a distinctive file icon. Let us now see how such a Batch file can be used to move one or more files from a folder from one place to another.
How to create folders using a Batch file
The Batch file you’ve just created can be used to create folders linked with this Batch file using a few simple lines of code. The good thing is that any folders you may create this way will move to the location that the original Batch file moves. Here’s what you need to do for this:
- Open Notepad as administrator and open the Batch file you’ve just created
- Paste the following lines of code:
@echo off md FolderName1 FolderName2 “Folder Name3"
- The above lines of code will help you create 3 folders namely; FolderName1, FolderName2, and Folder Name 3. If you wish for your folder’s name to have more than one word in it, you have to specify it by quoting the entire name as done above
- Now, save this file in the original .bat file extension and close Notepad
Now, revisit the .bat file in its original location and double-tap on it to make the recently made changes take effect. Upon doing so, you’ll realize that Windows will create 3 folders by the names you’ve just provided. The code above can be modified to create subfolders in these new folders. E.g., you can create a subfolder ‘materials’ in FolderName2 by entering the following command:
md FolderName1 FolderName2/Materials “Folder Name3"
This could help you further bifurcate and better manage your files.
Read: How to Run Batch Files silently in background on Windows
How to Move Multiple Files at once using a Batch file
There is a very easy process in place to move files from place to place. The only major requirement is for you to know the exact path of your destination folder to bulk transfer files. This is something you can easily seek from the folder properties by right-clicking on it. Let us now see how exactly the process of moving the files works. For this tutorial, we will be moving data from ‘FolderName1,’ which has 9 PDFs in it, to ‘FolderName2,’ which is empty.
- Open the File Explorer and visit the newly created folders, the ones between which we will be moving files
- Here, get the location of both the Source folder and the destination folder
- Open Notepad and select ‘Run as an administrator to create a new .bat file
- Here, use the ‘move’ command and post the following code:
move Source-Folder-Path*.* Destination-Folder-Path
- In our case, our code will look like this:
@echo off move C:\Users\lenovo\Desktop\"sample folder"\FolderName1\*.* C:\Users\lenovo\Desktop\"sample folder"\FolderName2
The ‘*.*’ here acts as a delimiter of sorts, which is used to let the program know that you want to move all the files from the source folder to the destination folder. Save this program document as a ‘.bat’ file, preferably in the same location as the original bundle of files and folders (for convenience).
Now, to execute this program, double-tap on the new command’s Batch file and wait for a while. You’ll find your Windows Explorer to refresh once, after which, you can check that the files, in this case, have moved from ‘FolderName1’ to ‘FolderName2,’ as evidenced by the picture below:
As you can see, all the PDF files were moved from the original folder to a new one in one go. This code can further be modified to include and move only a select few files from a folder. You can modify it further to only include files that have a particular file extension, like ‘.png’, ‘.jpeg’, etc.
In all the steps we followed above, we prefixed our executed codes with the keyword ‘@echo off’ which allowed you to bypass opening the command prompt for the Batch file to work, although intrinsically, a Batch file works via a command prompt only. Doing so is just time-effective and less overwhelming.
Can you move multiple files all at once into a folder?
Several keyboard shortcuts can also help you move multiple files at once. These may be time-consuming and a little boring to go through, but it saves you the hassle of going through code and executing it. For this purpose, you can use keyboard shortcuts such as; Click and Shift, holding Ctrl and going through the files, or selecting them all using Ctrl+A.
How do I automatically copy files from one folder to another in Windows 11/10?
If running a batch file to move multiple files in one go seems complicated to you, you can automate the execution of this process via the Windows Task Scheduler. In the Task Scheduler app, you can create a task, set a trigger, and under the action tab upload the script of the ‘.bat’ file to automatically copy files from one folder to the other.
We hope you find this helpful.