As educators we have a myriad of responsibilities, and administrative tasks can often eat into the time better spent in meaningful instruction and interaction with students. Technology, when leveraged correctly, can help lighten this load. In this post, I’m going to cover one such solution: Using Google Sheets and Google Apps Script, we’ll automate the process of creating and sharing individual Google Drive folders with your students, something I wish I’d done at the start of the school year rather than after spring break.

If you want me to make a YouTube tutorial let me know!

Why is this helpful?

When each student has a dedicated folder shared with them, they can “star” it, meaning it gets highlighted in their Google Drive for easy access. All their work, assignments, and returned papers are neatly organized in one place. In a later post, we will discuss how to automate the distribution of scanned exams and other materials into these folders, but let’s take one step at a time.

First, let’s look at how to set this up:

  1. Open your Google Sheets document.
  2. Click on Extensions > Apps Script.
  3. Delete any existing code in the script editor and replace it with the following:
function createAndShareFolders() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = sheet.getDataRange().getValues(); // Fetch all data in the sheet

for (var i = 0; i < data.length; i++) {
if (data[i][0] == "" || data[i][1] == "") {
// Stop the loop when an empty cell is found in either column
break;
}

var folderName = data[i][0];
var emailAddress = data[i][1];

// Create the folder in Google Drive
var folder = DriveApp.createFolder(folderName);

// Share the folder with the email address
folder.addEditor(emailAddress);
}
}
  1. Save the script with a name of your choice.
  2. Refresh your Google Sheets page.
  3. Navigate to Extensions > Apps Script Dashboard.
  4. Find your project, click on it and enable Google Workspace API access.
  5. Return to your Google Sheets page.

Before running the script, fill out your Google Sheets document with your students’ names (or desired folder names) in the first column and their email addresses in the second column.

Now, you can run the script! The script will create a Google Drive folder for each student and share it with them. They’ll have editing rights by default, allowing them to organize and manage their files within the folder.

A word of caution: Be sure that the email addresses are valid; otherwise, the script may fail.

This script provides your students with “Editor” privileges. If you want them to have only “Viewer” or “Commenter” rights, replace folder.addEditor(emailAddress); with folder.addViewer(emailAddress); or folder.addCommenter(emailAddress);, respectively.

After running the script, an individual Google Drive folder is created and shared for each student. All they have to do is accept the invitation, star the folder, and they’re all set! This process not only saves you a significant amount of time but also helps to keep your students’ assignments organized.

Next time, we’ll cover how to automate the distribution of scanned exams and other educational materials using similar methods. Until then, happy teaching, and enjoy the marvels of automation!

Bonus Code!

If you want to save time you can use the below script to create your sheet for you. This will pull all classes you are listed as a teacher of in Google Classroom and then print to Google Sheets three columns, first with course name, second student names, and third student emails. Before running the script, ensure that Classroom API is enabled. You can do this by clicking on Resources > Advanced Google Services in the Google Apps Script editor and toggling Classroom API to on. If Classroom API is not listed, you’ll need to enable it in Google Cloud Platform. Either modify the code or perform a digital cleanup manually for any required adjustments.

function createStudentList() {
var sheet = SpreadsheetApp.create('Student Info');

// Access Google Classroom
var courses = Classroom.Courses.list().courses;

// Array to hold all course data
var data = [];

// Loop through all courses
for (var i in courses) {
var course = courses[i];

// List all students in the course
var students = Classroom.Courses.Students.list(course.id).students;

// Loop through all students
for (var j in students) {
var student = students[j];

// Push to data array: [Course Name, Student Name, Student Email]
data.push([course.name, student.profile.name.fullName, student.profile.emailAddress]);
}
}

// Get the first sheet of the newly created Spreadsheet
var firstSheet = sheet.getSheets()[0];

// Set the headers
firstSheet.getRange(1, 1, 1, 3).setValues([['Course Name', 'Student Name', 'Student Email']]);

// Fill the sheet with the data
firstSheet.getRange(2, 1, data.length, 3).setValues(data);
}