When add-ons almost get the job done!

Sometimes we use Google Add-ons and think if it only did (insert most desirable feature request), it would be perfect. Where add-ons fall short, sometimes we can use our own apps script to complete the job. One shortcoming I’ve recently observed is the ability to send document merge jobs via Autocrat directly to a folder in a Shared Drive.

A small apps script can monitor a specific folder in My Drive, then move those files to a desired location in a Shared Drive. A demo video and sample code can be found below.

function moveFiles() {
  //Folder ID from Autocrat Destination
  var folder = DriveApp.getFolderById("AUTOCRAT_FOLDER_ID_GOES_HERE");
  var files = folder.getFiles();
  while (files.hasNext()) {
    const childFile = files.next();
    var info = [
      childFile.getId()
    ];
    var file = DriveApp.getFileById(info.toString());
    //Target Folder ID from Shared Drive
    var targetFolder = DriveApp.getFolderById("TARGET_SHARED_DRIVE_FOLDER_ID_GOES_HERE");
    file.moveTo(targetFolder);
  }
}