Bulk Create Google Drive Folder Structures & Files

Perfect for project managers, team leads, teachers or anyone who needs to set up a set of Google Drive folders and subfolders quickly

Bulk Create Google Drive Folder Structures & Files
Photo by Jan Antonin Kolar / Unsplash

This Apps Script is perfect for project managers, team leads, teachers or anyone who needs to set up a set of Google Drive folders and subfolders quickly and efficiently using automation instead of manual clicks.

Kudos to https://www.pbainbridge.co.uk/2020/06/bulk-create-google-drive-folders-20.html and various stackoverflow threads for filling in some gaps about how things work.

Bulk create Google Drive folders 2.0
Bulk create Google Drive folders using data from a spreadsheet for naming and adding permissions.

Overview:

  • Google Sheet stores the names of the folders & subfolders to be created
  • Specify the root folder(s) where the new hierarchy will be created
  • Specify the viewers or editors that should have access to each folder or subfolder
  • Specify documents (sheets, docs, files) that should be pre-loaded into each folder (like an agenda template, project instructions, team roster, etc)
  • Trigger the creation via a custom menu in the Google Sheet

Example:

You want to create a structure like this:

Main Folder: My Projects
….SubFolder: Project A
….….Sub-Sub-Folder: Project A Agendas
….….….File: Agenda Template Document
….….Sub-Sub-Folder: Project A Resources
….….…. File: Basic Resources.pdf
….SubFolder: Project B
….….Sub-Sub-Folder: Project B Agendas
….….….File: Agenda Template Document
….….Sub-Sub-Folder: Project B Resources
….….….File: Basic Resources for Project B.pdf

(and you want a different set of viewers/editors for the different folders)

Code

(if you already know what you're doing)

Procedure for the example:

  1. Copy the Google Sheet so it's owned by you
  2. Update the Google Sheet so it points to your own base/root folder (the one where all the other subfolders are going to be created)
  3. Use the examples already in the sheet (Team A etc) so you see how it works before you run it for your own purposes. You can just delete what's created afterwards anyway.
  4. Click the "Extensions" menu, then click "Apps Script"
  5. This will open the Apps Script editor.
  6. Update the variables if you want (you don't need to, but you can)
  7. With the "onOpen" function listed at the top, click "Run"
  8. This will popup a window asking for permissions, so you can let Apps Script run on your own account. It's you, granting permissions to your script, to have access to your content. Follow the prompts (even if it says "unsafe") and approve the access. Note, the unsafe part is because this is your code, and it's not an official source vetted and approved already by Google.
  9. After it runs successfully, close the script editor window and return to the Google Sheet.
  10. There should be a new menu item called "Neat Features" (if not, refresh the browser and it will show up).
  11. Click on the "Generate Folders" menu item to create your folders according to what's in the google sheet.
  12. That's it. Check the folder in google drive to see the new folders and template files that were placed inside them. Check the permissions too if you chose to set the Viewer/Editor stuff as well.
  13. That's really it.
  14. Add new rows to the sheet and run it again, and it will continue to work for anything else you add (but only after you click Generate Folders Now).

Hope this helps!

Check out this and other apps script code samples at: https://github.com/usaussie