ToSingleFile is a Python utility that recursively combines source code files into a single output file. Perfect for creating submissions, simplifying code reviews, or consolidating project artifacts.
- Extension Filtering: Combine specific file types (
.py
,.js
, etc.) - Exclusion Patterns: Skip files/directories using glob patterns
- Directory Traversal: Recursive file discovery
- Relative Path Annotations: Preserves original file locations as comments
- Automatic Exclusions: Skips venv directories, script itself, and output file
- Cross-Platform: Works on Windows, Linux, and macOS
- Python 3.6+
git clone https://github.com/2dameneko/ToSingleFile
python combine_files.py [folder_path] [output_file] [extension] [--exclude PATTERN]
Combine all Python files in current directory:
python combine_files.py
Combine JavaScript files in specific directory:
python combine_files.py ./src combined.js .js
Combine files excluding tests:
python combine_files.py --exclude "*_test.py" --exclude "tests/*"
Argument | Description | Default |
---|---|---|
folder_path |
Root directory to search | Current directory |
output_file |
Output filename | Combined.py |
extension |
File extension to include (with leading dot) | .py |
--exclude /-e |
Glob patterns to exclude files/directories (multiple allowed) | None |
# File: utils/helpers.py
def greet():
print("Hello World")
# File: main.py
import utils.helpers
helpers.greet()
- Always back up your code before combining
- Output file is overwritten automatically
- Exclusions are applied to relative paths
- Binary files are not supported
- Files are sorted lexicographically before combining
- 0.1 (Initial Release):
- Core combining functionality