Skip to content

Instantly share code, notes, and snippets.

@Lazzlo2096
Last active May 31, 2025 10:23
Show Gist options
  • Save Lazzlo2096/95e7491ec04ce7b062e57c1d1a7a7847 to your computer and use it in GitHub Desktop.
Save Lazzlo2096/95e7491ec04ce7b062e57c1d1a7a7847 to your computer and use it in GitHub Desktop.
Select multiple files and concatenate their content into a single plain-text file for AI input.

FileJoinerGPT β€” Prepare Your Code for GPT

FileJoinerGPT is a lightweight Python GUI tool that lets you select multiple source code or text files, view the selected list, and concatenate their contents into a single file β€” perfect for feeding into GPT or other large language models (LLMs).


🧠 Why use it?

LLMs like GPT often work best when given the full picture in a single input prompt. FileJoinerGPT helps you:

  • Combine multiple .py, .txt, .json, etc. files
  • Keep a persistent list of selected files across sessions
  • Export the full combined content into one .txt file
  • Stay focused: no distractions, no bloat, just what you need

βš™οΈ Features

  • βœ… Select multiple files through GUI
  • βœ… View full file list inside the app
  • βœ… Automatically remembers your last selection
  • βœ… One-click export to output.txt with filenames and content
  • βœ… Written in pure Python using tkinter (no dependencies)

πŸš€ How to run

🐍 Requirements

  • Python 3.6+
  • Tkinter (usually preinstalled)

On Ubuntu/Debian:

sudo apt install python3-tk
python3 ./FileJoinerGPT.py
#sudo apt update
#sudo apt install python3-tk
import os
import json
import tempfile
import tkinter as tk
from tkinter import filedialog, messagebox, scrolledtext
# Paths
SAVE_FILE = os.path.join(tempfile.gettempdir(), "selected_files.json")
OUTPUT_FILE = "output.txt"
def load_file_list():
if os.path.exists(SAVE_FILE):
with open(SAVE_FILE, "r", encoding="utf-8") as f:
return json.load(f)
return []
def save_file_list(file_list):
with open(SAVE_FILE, "w", encoding="utf-8") as f:
json.dump(file_list, f, indent=2)
def select_files():
files = filedialog.askopenfilenames(title="Select files")
if files:
file_list.clear()
file_list.extend(files)
update_display()
save_file_list(file_list)
def update_display():
display_text.delete(1.0, tk.END)
for f in file_list:
display_text.insert(tk.END, f + "\n")
def export_to_text():
if not file_list:
messagebox.showwarning("No files", "Please select files first.")
return
with open(OUTPUT_FILE, "w", encoding="utf-8") as out:
for file_path in file_list:
filename = os.path.basename(file_path)
try:
with open(file_path, "r", encoding="utf-8") as f:
content = f.read()
except Exception as e:
content = f"⚠️ Error reading file: {e}"
out.write(f"File {filename}:\n")
out.write("```\n")
out.write(content)
out.write("\n```\n\n")
messagebox.showinfo("Done", f"Content saved to {OUTPUT_FILE}")
def clear_file_list():
file_list.clear()
update_display()
save_file_list(file_list)
# GUI
root = tk.Tk()
root.title("CodeConcat β€” Prepare Your Code for GPT")
file_list = load_file_list()
tk.Button(root, text="Select Files", command=select_files).pack(pady=5)
tk.Button(root, text="Export to output.txt", command=export_to_text).pack(pady=5)
tk.Button(root, text="Clear List", command=clear_file_list).pack(pady=5)
display_text = scrolledtext.ScrolledText(root, width=80, height=20)
display_text.pack(padx=10, pady=10)
update_display()
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment