List all files and folders in a selected folder’s directory tree in Google Drive: Apps Script

If you have ever tried to get a list of all the child files and folders of a parent folder in Google Drive, you’ve no doubt discovered that it is a slow old process. Iterating over each item in a folder and then reading the metadata of that file or folder before calling the next one can take forever!

The built-in DriveApp Class for Google Apps Script is great for working on a small number of files and folders but it just doesn’t have the functionality to retrieve specific fields in your metadata, nor does the searchFiles method or searchFolders method have the ability to isolate just the fields that you want to retrieve. Subsequently, your processing time increases significantly as it ships junk data.

This tutorial is my attempt at, as the kiddies say today, creating a ‘blazingly fast’  file and folder iterator with Google’s Drive API v2 for Apps Script.

Continue reading “List all files and folders in a selected folder’s directory tree in Google Drive: Apps Script”

Automatic download link for non-Google Workspace files in Google Drive

Ever wanted your users to simply click a button on your webpage and,?, a file you saved on Google Drive is automatically downloaded for them?

Here have a look at two examples:

NOTE! Clicking the links above will automatically download the file described.

This quick tool allows you to do just that. It works with any file like:

  • Images e.g. *.png *.jpg.
  • Documents e.g. *.pdf *.doc.
  • Zip files e.g. *.zip *.7z.
  • Pretty much anything that isn’t a Google Workspace file like a Google Sheet, Google Doc, Google Slide.

Grab and set up the file

    1. Find the file you need to set up for auto-download.
    2. Righ-click the file.
    3. Select Get link.
    4. Ensure the settings says, Anyone with link can view.
    5. Select Copy link.
Google Drive get link example
Click to expand!

Create the link

*Wait for the converter to load.

Do no harm!

Yes, I guess this could be used for downloading some nefarious content. This little tool is designed to provide a convenience for you and the people you want to share your files with. Please consider other people when preparing a tool for them. Even a quick heads up in your own content might be a good idea:

  • Note! File will download automatically from Google Drive.
  • Note! Clicking this file will download it automatically.

What about my Google Workspace Files?

Not directly with this tool, I’m afraid. The simple answer is Google Workspace files are designed to be in Google Drive and online. Much better for you to share the file publically and then provide a link to the file.


If you are intending on providing your Google Workspace files or folders for your users to download and use offline anyway then you could download the in advance. This will cause the Google Workspace files to be exported into an offline format. Then you can drag that converted file and put it back in your drive and share it. You will be able to complete the steps above then.

Also, if you are downloading an entire folder it will export it files into usually Microsoft formats for you automatically and save the entire document in a zip file. Then you can drag that zip file back into your Google Drive and convert with the above too.

Neat huh?



Google Apps Script: Create multiple versions of a document based on Google Sheet Data and a Google Doc Template (Mail Merge)

Google Apps Script: SpreasheetApp, DocumentApp, DriveApp; Google Sheets, Google Docs

If you have ever worked in LibreOffice or Microsoft Excel you will probably be familiar with the mail merge. Traditionally, mail merge is used to create multiple versions of a document and snail-mail them to someone.

These days, we don’t often use the snail mail approach, but it is a regular occurrence for us to need to produce multiple versions of reports based on a data set usually from a spreadsheet.

In this tutorial, we will create a document merger that will create new Google Documents based on a dataset from a Google Sheet using Google Apps Script.

If you want to quickly jump into your own project with our script, I’ll provide you with a quick-use guide.

Then, we will set up a template for our Google Doc and generate our Google Sheet data (don’t worry, I’ll share the document so you can follow along).

Finally, we will jump into the breakdown of the code for those legends who are learning how to create their own Google Apps Script.

Let’s get started:

Note: As always, take what you need and don’t worry about the rest. 

Continue reading “Google Apps Script: Create multiple versions of a document based on Google Sheet Data and a Google Doc Template (Mail Merge)”