A simple Python tool for merging multiple .txt files into a single file while preserving their original structure through a generated map file.
This tool is especially useful for:
- Game translation projects
- Batch text editing
- Subtitle or script localization
- AI-assisted translation workflows
- Merge all TXT files in a folder into one
merged.txt - Automatically generate a
merged.mapfile - Restore the original TXT files after editing or translation
- Preserve original file encodings
- Supports unknown encodings using automatic detection
- Clean CLI interface with colored output
The tool:
-
Scans a folder for
.txtfiles -
Combines all lines into a single
merged.txt -
Creates a
merged.mapfile containing:- Original filename
- Line number
- Original encoding
After editing or translating merged.txt, the tool:
- Reads the map file
- Splits the merged text back into the original files
- Restores them with their original encodings
Install dependencies:
pip install chardet coloramaRun the script:
python main.pyThen choose:
1→ Merge TXT files2→ Restore original files
TXT_Merged/
└── merged.txt
Map_Merger/
└── merged.map
Output_TXT_Files/
└── restored txt files...
Nariman