How to automate copying Google Docs content to fresh documents using scripts

I’m trying to figure out how to use Google Apps Script to automatically transfer content from an existing Google Doc into a newly created document.

Background: My team creates weekly meeting notes and we always start by copying the previous week’s document format. Right now we do this manually by duplicating the file, but I want to automate this process.

Is there a way to write a script that can:

  • Open our template document
  • Copy all the text and formatting
  • Create a brand new Google Doc
  • Paste everything into the new file

I’ve looked into Google Apps Script but I’m not sure which methods to use for copying document content. Any code examples or guidance would be really helpful!

I built something like this for my department six months ago. Skip the manual copying - use DocumentApp.openById() to access your template, then getBody().copy() to grab everything including formatting. Create a new doc with DocumentApp.create() and use appendParagraph() or insertText() to add the copied content. Here’s what I learned the hard way: handle different element types separately. Tables, images, and regular text each need different approaches. You’ll need to iterate through each element in the original doc’s body and recreate it in the new one. Set up proper error handling too - API calls can timeout with larger documents. My script runs automatically every Monday morning using time-based triggers. Saves our team about 15 minutes each week.

Both work, but the best method depends on what you need. If you’re modifying template content during creation (updating dates, clearing sections), copy elements individually for more control. Just duplicating the exact structure? Use makeCopy().

Watch out though - makeCopy() preserves shared content and linked elements, which might not be what you want. I use a hybrid approach: makeCopy() first, then replaceText() to update placeholders like dates or meeting numbers. You can also set up the script to auto-rename files with current dates and move them to specific folders using DriveApp methods.

theres an easier way than copying element by element. just use the makeCopy() method on the document object - it duplicates everything perfectly including formatting and images. something like DriveApp.getFileById(templateId).makeCopy('new doc name'). way simpler than rebuilding content manually and works great for weekly templates.