folder_action_concatenate.sh

#!/bin/bash

# Define the folder and output file
FOLDER="$HOME/Desktop/FOR_LLM_UPLOAD"
OUTPUT="$FOLDER/combined_output.txt"

# Create the folder if it doesn't exist
mkdir -p "$FOLDER"

# Clear the output file
echo "" > "$OUTPUT"

# Loop through all files in the folder
for FILE in "$FOLDER"/*; do
  BASENAME=$(basename "$FILE")
  if [[ "$BASENAME" != "combined_output.txt" && -f "$FILE" ]]; then
    echo "--- FILE: $BASENAME ---" >> "$OUTPUT"
    cat "$FILE" >> "$OUTPUT"
    echo -e "
" >> "$OUTPUT"
  fi
done

If you’re using a free or limited LLM to check coding etc. this script is a workaround to limits for how many files you can upload. It puts them all together into a file called combined_output.txt and adds the name of the file as section headings. Then you can upload just this one file to an LLM to check and it usually reads the section breaks correctly.

  1. Copy the above code into a plain text file and name it: folder_action_concatenate.sh
  2. Make a folder called FOR LLM UPLOAD on your desktop
  3. Place all your files into folder on your desktop called “FOR LLM UPLOAD” The script automatically joins the files together and gives a header section of each file name. It saves it as combined_output.txt. You can then upload that for a quesry in an LLM.