koep/gdoc-merger

★ 0Forks 0JavaScriptGitHub ↗Compare

README

Google Docs Merger

Merges the plain text of many Google Docs into a single target Google Doc. Resumable, idempotent, timeout-safe.

Architecture

flowchart LR
    A["Source Folder\n(Google Drive)"] -->|recursive scan| B["Code.gs\n(Apps Script)"]
    B -->|filter by year\nexclude folders\nsort newest→oldest| C[Candidate Docs]
    C -->|export as\nplain text| B
    B -->|chunked append| D["Target Doc\n(Google Docs)"]
    B <-->|merged ID cache| E["ScriptProperties"]
    D -->|"[MERGED_ID] markers\n(idempotency)"| B
Loading

Getting Started

  1. Go to script.new and create a new project.
  2. Replace Code.gs contents with the script from this repo.
  3. Enable Show "appsscript.json" manifest in Project Settings, then replace it with the one from this repo.
  4. Enable Drive API in the linked GCP project (Project Settings → GCP Project → APIs & Services → Enable).
  5. Set your IDs at the top of Code.gs:
const FOLDER_ID     = 'your-source-folder-id';   // Drive URL: /folders/<ID>
const TARGET_DOC_ID = 'your-target-doc-id';       // Doc URL: /document/d/<ID>/
  1. Run previewOrder() to verify the doc list looks right.
  2. Run mergeFast() to merge. Schedule it via Triggers for automatic recurring runs.

Contributors

koep

Issues