A Windows context menu utility that "flattens" folder hierarchies by moving all nested files to a root directory.
folderFlattener recursively moves all files from subdirectories into a single root directory while maintaining clear naming to avoid file collisions. This is useful for:
- Extracting all files from deeply nested archive structures
- Organizing downloads scattered across multiple folders
- Consolidating files from complex directory hierarchies
- Cleaning up folder structures while preserving file organization through naming
- Recursive file extraction: Moves all nested files to the root directory
- Smart naming: Renames files to include their original subdirectory path (e.g.,
subfolder_filename.ext) - Collision prevention: Automatically handles duplicate filenames with numeric suffixes
- String filtering: Removes unwanted strings from filenames (customizable in the script)
- Partial file cleanup: Removes incomplete
.partfiles (common in downloads) - Automatic cleanup: Deletes empty subdirectories after file extraction
- Context menu integration: Right-click on any folder to flatten it
- Safe operations: Uses literal path handling to avoid issues with special characters
- Download or clone this repository
Or download the ZIP file and extract it
git clone https://github.com/yourusername/folderFlattener.git
- Run
install.batas Administrator - The script will be installed to
Program Files\folderFlattenerand registered with Windows Registry - After installation completes successfully, you can delete the downloaded/extracted files - they are no longer needed
- Restart Windows Explorer (or log out and back in) to apply the context menu changes
- The context menu shortcut will now appear when you right-click any folder
Bonus:
Configure C:\Program Files\folderFlattener\main.ps1 on line 60 to customize unwanted strings to remove from filenames
- Right-click any folder in Windows Explorer
- Select "Flatten Folder" from the context menu
- Wait for the operation to complete
powershell -File main.ps1 -WorkingDir "C:\path\to\folder"When you flatten a folder:
- All files from subdirectories are moved to the root directory
- Files are renamed with their original path prepended (e.g.,
subfolder\file.txt→subfolder_file.txt) - If a file already exists, a numeric suffix is added (e.g.,
subfolder_file_1.txt) - Unwanted strings are removed from filenames (configurable in the script)
- Incomplete
.partfiles are deleted - Empty subdirectories are automatically removed
Before:
MyFolder/
├── Downloads/
│ ├── file1.txt
│ └── subdownloads/
│ └── file2.pdf
├── Archives/
│ └── report.docx
└── file3.jpg
After:
MyFolder/
├── file3.jpg
├── Downloads_file1.txt
├── Downloads_subdownloads_file2.pdf
└── Archives_report.docx
Run uninstall.bat as Administrator to remove the context menu integration and the script files.
- Windows 7 or later
- PowerShell 3.0 or later (included with Windows 7 SP1+)
- Administrator privileges (for registry modifications during installation)
See LICENSE file for details.
- Icon: Move To Folder by Icons8
Context menu made "sexy" with IMA-Menu