SaveCodeToTXT is a Python tool that allows you to save all your code into text files for later use in fine-tuning ChatGPT models or simply to maintain a readable archive of your code. This tool helps developers create text datasets from their code, which can be used for training GPT models or for storing code in an organized manner.
- Save all your project’s code: Generate
.txt
files containing your code for all directories in your project. - Easily exclude files/directories: Double-click on a file or directory to exclude it from the generation.
- Automatic exclusions: Automatically excludes the
node_modules
folder and files specified in.gitignore
. - User-friendly interface: Includes an intuitive user interface built with Tkinter.
Generate .txt
files containing your entire project’s code, which can then be used for training or fine-tuning GPT models by loading them into a training environment.
For large projects with many code files, SaveCodeToTXT helps you create structured text datasets of your codebase. This can be useful if you are training your own model to understand your project’s specific code style and structure.
Before using SaveCodeToTXT, ensure Tkinter is installed on your system.
sudo apt-get install python3-tk
brew install python-tk
Tkinter is usually included with the standard installation of Python. If not, install Python from the official site and ensure Tkinter is included.
git clone https://github.com/your-username/SaveCodeToTXT.git
cd SaveCodeToTXT
python3 savecodetotxt.py
A window will open, where you can select the project folder to analyze.
- Double-click on a file or directory to add an
[X]
next to its name. This indicates that it will be excluded from the.txt
generation. - Double-click again to remove the
[X]
and include the file or directory.
Click the "Generate txt files" button. The .txt
files will be created in a folder named your-project_txt
within the current directory.
The generated .txt
files are organized as follows:
- File Name: Each text file is named after the source code file.
- File Path: The text file includes the original file path for easy reference.
- File Content: The content of each file is stored in the
.txt
.
Additionally:
- A
base.txt
file collects all files from the root directory. - Each top-level directory generates a single
.txt
file combining all files and subdirectories into one.
The following directories and files are automatically excluded when selecting a project folder:
- node_modules: Ignored by default to avoid unnecessary dependencies.
- .gitignore files: Files and directories listed in the
.gitignore
are automatically excluded.
Contributions are welcome! To contribute to SaveCodeToTXT, follow these steps:
- Fork the project.
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add new feature'
- Push the branch:
git push origin my-new-feature
- Open a pull request for review.
This project is licensed under the MIT License.