This post will show you how to move all files from subfolders to main folder in Windows 11/10. It’s a very time-consuming process to move multiple subfolders containing files into a single folder. Fortunately, Windows offers some in-built features for moving or copying all files from subfolders to the main folder. Keep reading this post to learn about these features.
Move All Files from Subfolders to Main Folder in Windows
Follow these methods to move all files from subfolders to the main folder:
- Using Command Prompt
- Using PowerShell
- Using File Explorer
- Using Batch File
Let’s now see these in detail.
1] Using PowerShell
Here’s how you can move files from subfolders to the main folder using PowerShell:
- Open PowerShell as an Admin.
- Type this command and hit Enter.
New-Item -ItemType Directory -Path "FolderPath"
- This command will create a new folder where the files will be moved. Replace FolderPath with the location’s path where you want to create the folder.
- Now, type this command and hit Enter:
Set-Location -Path "SubfolderLocation"
- This command will modify the current directory to the source folder containing subfolders to be transferred. Replace SubfolderLocation with the subfolder’s location.
- Finally, run this command to copy all the files in the subfolders to a main folder. Here, replace MainFolder with the destination folder’s location.
Get-ChildItem -Recurse -File | Copy-Item -Destination "MainFolder"
2] Using Command Prompt
Follow these steps to move or copy files and folders using Command Prompt:
- Open Command Prompt as an Admin.
- Type the following command and hit Enter. This will create a new folder for moving or copying the files. Make sure to replace MainFolder with the path where the folder needs to be created.
- Once the destination folder has been created, you need to modify the current directory to the source folder containing the subfolders. Run this command to do so. Make sure to replace SubFolderpath with the subfolder’s path.
cd /d "SubFolderpath"
- Finally, run this command to copy all the files in the subfolders to a main folder. Replace MainFolderPath with the destination folder’s path.
for /r %d in (*) do copy "MainFolderPath"
Note: In the final command, you can replace copy with move if you want to move the files instead of copying them.
3] Using File Explorer
In this method we’ll be using the File Explorer to move files from subfolders to a main folder. Here’s how:
- Open the File Explorer and navigate to the folder containing subfolders to be moved.
- Type the following command in the search bar and hit Enter. This command orders the File Explorer to exclude all folders from the search results, i.e., only the files will appear.
*.* NOT type:"file folder"
- Now, press CTRL + A to select all the files and cut or copy these files as per your preference.
- Navigate to the main folder and press CTRL + V to paste all the files.
Read: Can’t drag and drop files or folders in Windows
4] Using Batch File
Creating and running a batch file will run different commands to move files and folders from one location to another. Here’s how:
- Open Notepad and paste the following code:
@echo off set SOURCE_FOLDER=FolderWithSubfoldersPath set DESTINATION_FOLDER=MainfolderPath if not exist "%DESTINATION_FOLDER%" ( mkdir "%DESTINATION_FOLDER%" ) for /r "%SOURCE_FOLDER%" %%f in (*) do ( move "%%f" "%DESTINATION_FOLDER%\" ) echo All files have been moved to %DESTINATION_FOLDER%. pause
- Now save this file with a .bat extension. Ensure to replace MainfolderPath with the destination folder path and FolderWithSubfoldersPath with the subfolders folder path.
- Run the batch file as an admin, and the command will execute.
Voila, you’ve now successfully moved all files from subfolders to the main folder in Windows.
Read: No Duplicate Warning when Copying or Moving Files and Folders
We hope this post helped you.
Is there a way to move files from multiple folders at once?
Yes, Windows offers multiple features for moving files from various folders simultaneously. You can do so by running the *.* NOT type:”file folder” in file explorer and copying and pasting the files. Other than that, using Command Prompt and PowerShell can also make it work.
How to remove all files from subfolders and relocate them to one folder?
You can remove all files from subfolders and relocate them to one folder simply by pressing CTRL +A to copy them and CTRL + X to cut them. Then navigate to the destination folder and press CTRL + V to paste the files.