Move All Files from Subfolders to Main Folder (Windows)

Published by Nyau Wai Hoe - Updated on

If you need to move a lot of files from many subfolders into one main folder on your computer, doing it manually by hand can be really slow and boring. Thankfully, Windows has some built-in methods that you can use to quickly move or copy all your files from the subfolders to a single folder. In this guide, we’ll show you different methods to do this on Windows 11 and Windows 10.

Also see: How to Batch Rename Files in Windows 11

Move All Files from Subfolders to Main Folder

Why do you need to move or copy all files from subfolders to the main folder?

There can be many reasons why you would need to move or copy files from lots of smaller folders into one big folder. Maybe you want to back up everything to one place, or you just need to move all your pictures and videos from different folders on your phone to your PC so you can organize them better.

Suggested read: How to Compare Two Folders in Windows 11

1st method: Use PowerShell

One method is to use PowerShell with some useful commands to move your files the way you want.

  1. Open the Start menu and type “PowerShell“.
  2. Right-click on “Windows PowerShell” and choose “Run as administrator“.Windows 11 PowerShell Run as administrator
  3. Create a new folder where all the files will be moved or copied by typing:
    New-Item -ItemType Directory -Path "c:\MainFolder"
    This command will create a new folder called “MainFolder” on your C: drive. You can change “c:\MainFolder” to a different path and name if you want. how mass copy files from inside different folders
  4. Change to the folder that has the subfolders with this command:
    Set-Location -Path "c:\FolderWithSubfolders\"
    This makes “c:\FolderWithSubfolders\” the active directory, which is where your subfolders are.
  5. To copy all the files from the subfolders to the new folder, type:
    Get-ChildItem -Recurse -File | Copy-Item -Destination "c:\MainFolder\"
    This command will find all the files in the subfolders and copies them to “c:\MainFolder\”. If you’d rather move the files, you can swap “Copy-Item” with “Move-Item“.Copy files from multiple folders to one folder PowerShell

If there’s already a file with the same name in the destination, the system will automatically ask if you want to replace it.

2nd method: Use Command Prompt

Another more straightforward approach is to just use the Command Prompt for the job. With only 3 lines of commands, you should be able to move or copy files from all subfolders to a main folder.

  1. Open the Start menu and search for “cmd“.
  2. Right-click on Command Prompt and choose “Run as administrator“.Command Prompt Run as Administrator
  3. Create a new folder for the files by typing:
    md "c:\MainFolder"
    This sets up a new directory named “MainFolder” on your C: drive. You can name it something else if you prefer.
  4. Change to the directory that holds the subfolders with this command:
    cd /d "c:\FolderWithSubfolders\"
    This makes “c:\FolderWithSubfolders\” the current working directory.
  5. To copy all the files from the subfolders to the new folder, use this command:
    for /r %d in (*) do copy "%d" "c:\MainFolder\"
    This loops through all the files in the subfolders and copies them to “c:\MainFolder\”. If you want to move the files instead, just change “copy” to “move”.Copy all files on subfolder to single folder cmd

Just like before, if a file with the same name exists in the destination folder, you’ll get a prompt to decide whether to overwrite it or skip it.

3rd method: File Explorer search

The File Explorer search function can help you find all files in a folder and its subfolders by file type, size, or when they were last changed. It’s also a good workaround for moving or copying all files from subfolders to the main folder when you do it right. Here’s how to do it:

  1. Open File Explorer and go to the folder that has the subfolders with the files you want to move or copy.
  2. Put this in the Search bar and hit Enter:
    *.* NOT type:"file folder"
    This *.* means look for all files, no matter their name or type. NOT type:"file folder" tells File Explorer to leave out folders from your search results, showing only the files.how to move files out of multiple folders
  3. Wait for the search to finish. If the search is slow, check out: How to Speed Up Search in File Explorer.
  4. Press Ctrl + A to select all files.Move all files from subfolders to main folder Windows 11
  5. Right-click on the selected files and choose Cut or Copy if you want to copy the files.
  6. Go to the main folder and paste the files there.

Tip: For a more targeted search, like for just video files or pictures, you can use the “kind” parameter in File Explorer on Windows 11 or Windows 10. More on this here.

Search only picture files If you have many subfolders and want to move all the files without keeping the subfolder structure, this method is very handy.

Related issue: “This Folder is Empty” in Windows 11 (Fix)

4th method: Use a batch file

A batch file is a small file that can contain a script that runs a series of commands one after the other. You can use it to do all sorts of things, including moving files.

@echo off
set SOURCE_FOLDER=C:\Mainfolder\
set DESTINATION_FOLDER=c:\FolderWithSubfolders\

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

Batch file to move files from subfolders to one folder Copy the codes above into a new text file, change the source and destination folder paths as needed, and save it as “copyfiles.bat”. When you run this batch file, it will automatically move all files from the source folder’s subfolders to the destination folder.

move files from multiple folders to one folder

Some tips you might want to know

Before moving or copying any files from subfolders to the main folder using any of the discussed methods, check for any duplicate filenames to prevent losing data because of unwanted overwriting.

You might want to consider using a file synchronization tool like FreeFileSync or SyncToy to automate the moving or copying of your files. These tools can compare files in both the source and destination folders and handle the files that are new or have changed.

You might also want to back up the whole folder before you move them, just in case things go south.

If you need to move or copy files from many different folders into one, you can use the same methods we’ve talked about by simply changing the path of the source folders in the commands or scripts.

These methods should work on Windows 11 and Windows 10, and might also work on older Windows versions with some small changes to the commands.


Nyau Wai Hoe
Nyau Wai Hoe is the Founder and Chief Editor of WindowsDigitals.com. With a degree in software engineering and over 12 years of experience in the tech support industry, Nyau has established himself as an expert in the field, with a primary focus on the Microsoft Windows operating system. As a tech enthusiast, he loves exploring new technologies and leveraging them to solve real-life problems.

Share via
Copy link