VS Code File Aggregator Extension
Overview
The File Aggregator Extension is a powerful VS Code tool designed to combine multiple files of the same type into a single aggregated file. It's particularly useful for developers who need to merge multiple source files while maintaining proper import statements and file organization.
Features
- 🔍 Recursively scans directories for files
- 🗂 Supports multiple file types (.py, .js, .ts, .cs)
- 🔄 Intelligent import handling and deduplication
- ⚡ Smart sorting options (by name or modification date)
- ⚙️ Configurable exclusion patterns
- 🎯 Preserves file structure and comments
Installation
From VS Code Marketplace
- Open VS Code
- Click on the Extensions icon in the Activity Bar
- Search for "File Aggregator"
- Click Install
Manual Installation
- Download the
.vsix
file from the releases page
- Open VS Code
- Press
Ctrl+Shift+P
(Windows/Linux) or Cmd+Shift+P
(macOS)
- Type "Install from VSIX" and select it
- Choose the downloaded
.vsix
file
Usage
Basic Usage
- Right-click on a folder in the VS Code explorer
- Select "Aggregate Files" from the context menu
- Choose the file extension you want to aggregate
- Select your sorting preference
- The aggregated file will be created in the selected folder
Command Palette
You can also trigger the aggregation through the command palette:
- Press
Ctrl+Shift+P
(Windows/Linux) or Cmd+Shift+P
(macOS)
- Type "Aggregate Files"
- Select a folder when prompted
Configuration
The extension can be configured through VS Code settings. You can modify these settings in your settings.json
file:
{
"fileAggregator.excludedFolders": [
"node_modules",
".git",
"dist",
"build",
"__pycache__"
],
"fileAggregator.excludedFiles": [],
"fileAggregator.omitUnderscoreFiles": false
}
Available Settings
Setting |
Description |
Default |
fileAggregator.excludedFolders |
Folders to exclude from aggregation |
["node_modules", ".git", "dist", "build", "__pycache__"] |
fileAggregator.excludedFiles |
Specific files to exclude |
[] |
fileAggregator.omitUnderscoreFiles |
Whether to exclude files starting with underscore |
false |
Features in Detail
Import Handling
The extension intelligently handles imports across different file types:
Python:
- Handles
import
and from ... import
statements
- Deduplicates imports
- Preserves relative imports
JavaScript/TypeScript:
- Supports ES6 imports and CommonJS requires
- Handles dynamic imports
- Maintains import order
C#:
- Manages
using
statements
- Consolidates namespace imports
- Preserves using static directives
Sorting Options
- By Name: Alphabetically sorts files
- By Date Modified: Sorts files by last modification time (newest first)
File Organization
The aggregated file will be structured as follows:
- Import statements (deduplicated)
- Empty line separator
- File content sections, each preceded by a comment indicating the source file
- Empty lines between different file contents
Error Handling
The extension includes robust error handling for common scenarios:
- Invalid folder selection
- Unsupported file types
- File access permissions
- Duplicate file names
- Import conflicts
Best Practices
For optimal results:
- Organize your files in a clean directory structure
- Keep import statements at the top of your files
- Use consistent import styles within your project
- Review the aggregated file before using in production
Known Limitations
- Maximum file size limit: 50MB per file
- Does not handle circular dependencies
- Some language-specific imports might need manual adjustment
- Binary files are not supported
Troubleshooting
Common Issues and Solutions
Files Not Found
- Check excluded folders settings
- Verify file permissions
- Ensure correct folder selection
Import Errors
- Review import statement formatting
- Check for circular dependencies
- Verify file path references
Performance Issues
- Reduce the number of files being processed
- Exclude unnecessary folders
- Check file sizes
Contributing
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have questions:
- Check the FAQ
- Search existing issues
- Create a new issue if needed
Changelog
See CHANGELOG.md for all notable changes.
Contributors
Thanks to all our contributors who help make this extension better!
📝 For more information and updates, visit our GitHub repository.