-1

Our organization creates the same folder structure with templated documents for each job. Right now staff manually creates each folder and within those folder creates each document from a template in the organizations template gallery. Is there a simple-ish way to automate this?

player0
  • 124,011
  • 12
  • 67
  • 124
Dillfrei
  • 1
  • 1
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Nov 21 '21 at 07:50

1 Answers1

0

This is how I would approach this if you would want to create a simple automated sheet script for it.

function createFolder() {

var ss = SpreadsheetApp.getActiveSpreadsheet();
var getFolderID = ss.getRange('A2').getValue();
var setFolderName = ss.getRange('B2').getValue();
var setDocName = ss.getRange('C2').getValue();
var setTemplate = ss.getRange('D2').getValue();

var drive = DriveApp;
var parentfolder = drive.getFolderById(getFolderID);
var newFolder = parentfolder.createFolder(setFolderName);
var createDoc = DocumentApp.create(setDocName);
var getDocID = createDoc.getId();
    
drive.getFileById(getDocID).moveTo(newFolder).setContent(setTemplate);
}

What this does is I created a sheet template like this: sample

Set the Parent Folder ID on cell A2 which you can find on the folder URL "https://drive.google.com/drive/folders/{parentfolderID}?resourcekey"

Set the folder name on cell B2, as well as the document name on C2 and your template on D2.

You can run the script by going into Tools > Script Editor, or you can assign an image to act as a button and assign the script to that image.

Running the script would result into this folder hierarchy enter image description here

with the value of D2 inside the Google Doc. enter image description here

References:

  1. https://developers.google.com/apps-script/reference/document/document-app
  2. https://developers.google.com/apps-script/reference/drive/drive-app
  3. https://developers.google.com/apps-script/reference/spreadsheet/sheet
Century Tuna
  • 1,378
  • 1
  • 6
  • 13