bit.ly/giffnamethosedocs

Below is a list of the versions of Name Those Docs!

NOTE:  As of Sep 2018, Google made some changes and the interface for the script is not working IN SOME CASES but the functionality is!  I will try to fix it but in the meantime, if it doens’t seem to be working, please use the Script, not the Template.  

Click for instructions to use the script 

Choose the one that works best for you, and click template.

See my blog post or video for instructions

Wondering which one to choose?  Check out this flowchart

✅Name Those Docs! Version A

Data entered: Full name, email

Access: view only access by students

Template | Script

✅Name Those Docs! Version B

Data entered: Full name, email

Access: Edit access by students

Template | Script

✅Name Those Docs! Version C

Data entered: Full name only

Access: No access by students

Template | Script

✅Name Those Docs! Version D

Data entered: Student Number, First Name, Last Name, email

Access: View only access by students

Template | Script

✅Name Those Docs! Version E

Data entered: Student Number, First Name, Last Name, email

Access: Edit access by students

Template | Script

✅Name Those Docs! Version F

Date entered: Student Number, First Name, Last Name

Access: No access by students

Template | Script

To use the script:

  1. Open the spreadsheet with the roster
  2. Go to Tools → Script Editor.  (A new window will open)
  3. Erase any script/writing and paste a script from below
  4. Hit the Save Icon and name the script (can be named anything)
  5. Hit the Run button
  6. Toggled back to the spreadsheet and answer the prompt.


Version A

//this function makes a doc for each student

//gives each student view only access

//needs to include email address

//full name in Col 1

function docMaker(){

  var ss = SpreadsheetApp.getActiveSpreadsheet();

  var sheet = ss.getSheets()[0];//get first sheet

 

  var last = sheet.getLastRow();//end of roster size

 

  sheet.getRange('C2').setValue('Doc Name');

  sheet.getRange('D2').setValue('Doc ID');

  sheet.getRange('E2').setValue('Doc URL');

 

  //prompt for Folder Name

 

  var ui = SpreadsheetApp.getUi();

  var ask = ui.prompt('What do you want to name the teacher folder? \nStudent Docs will go inside this folder.');

  var response = ask.getResponseText();

 

  //Create a teacher folder

 

  var tFolder = DriveApp.createFolder(response);

  var tFolderId = tFolder.getId();//ID to teacher folder

  var tFolderUrl = tFolder.getUrl();//URL to teacher folder

  sheet.getRange('A1').setValue('Teacher Folder');//put teacher folder info in row 1

  sheet.getRange('B1').setValue(response);

  sheet.getRange('C1').setValue(tFolderUrl);

  sheet.getRange('D1').setValue(tFolderId);

  sheet.getRange('E1').setValue(' ');

 

  //Student folder names

 

  var ask2 = ui.prompt('If you want any text to appear after the student name, enter is here (e.g. Observations).  \nNote: It can be blank');

  var response2 = ask2.getResponseText();

 

  //call the document to be copied

   

  Logger.log('last '+last);

  for(var i=3;i<last+1;i++){

   

    var student = sheet.getRange(i, 1).getValue();//get student name

    var email = sheet.getRange(i,2).getValue();//get student email

    var folder = DocumentApp.create(student + ' '+response2);

    var sFolder = folder.getName();

    var sFolderId = folder.getId();

    var sFolderUrl = folder.getUrl();

    folder.addViewer(email); //add student as an editor of the folder

    sheet.getRange(i,3).setValue(sFolder);

    sheet.getRange(i,4).setValue(sFolderId);

    sheet.getRange(i,5).setValue(sFolderUrl);

   

    //Add student folders to teacher folder

    var teacherFolder = DriveApp.getFolderById(tFolderId);

   

    var studentFolder = DriveApp.getFolderById(sFolderId);

   

    teacherFolder.addFolder(studentFolder);//put student folder in teacher folder

   

    DriveApp.getRootFolder().removeFolder(studentFolder);//take student folder out of Google Drive

  }

 

}

 

Version B

//this function makes a doc for each student

//gives each student editable access

//needs to include email address

//full name in Col 1

function docMaker(){

  var ss = SpreadsheetApp.getActiveSpreadsheet();

  var sheet = ss.getSheets()[0];//get first sheet

  var last = sheet.getLastRow();//end of roster size

 

  sheet.getRange('C2').setValue('Doc Name');

  sheet.getRange('D2').setValue('Doc ID');

  sheet.getRange('E2').setValue('Doc URL');

 

  //prompt for Folder Name

 

  var ui = SpreadsheetApp.getUi();

  var ask = ui.prompt('What do you want to name the teacher folder? \nStudent Docs will go inside this folder.');

  var response = ask.getResponseText();

 

  //Create a teacher folder

   var tFolder = DriveApp.createFolder(response);

  var tFolderId = tFolder.getId();//ID to teacher folder

  var tFolderUrl = tFolder.getUrl();//URL to teacher folder

  sheet.getRange('A1').setValue('Teacher Folder');//put teacher folder info in row 1

  sheet.getRange('B1').setValue(response);

  sheet.getRange('C1').setValue(tFolderUrl);

  sheet.getRange('D1').setValue(tFolderId);

  sheet.getRange('E1').setValue(' ');

 

  //Student folder names

   var ask2 = ui.prompt('If you want any text to appear after the student name, enter is here (e.g. Observations).  Note: It can be blank');

  var response2 = ask2.getResponseText();

 

  //call the document to be copied

   

  Logger.log('last '+last);

  for(var i=3;i<last+1;i++){

   

    var student = sheet.getRange(i, 1).getValue();//get student name

    var email = sheet.getRange(i,2).getValue();//get student email

    var folder = DocumentApp.create(student + ' '+response2);

    var sFolder = folder.getName();

    var sFolderId = folder.getId();

    var sFolderUrl = folder.getUrl();

    folder.addEditor(email); //add student as an editor of the folder

    sheet.getRange(i,3).setValue(sFolder);

    sheet.getRange(i,4).setValue(sFolderId);

    sheet.getRange(i,5).setValue(sFolderUrl);

   

    //Add student folders to teacher folder

    var teacherFolder = DriveApp.getFolderById(tFolderId);

   

    var studentFolder = DriveApp.getFolderById(sFolderId);

   

    teacherFolder.addFolder(studentFolder);//put student folder in teacher folder

   

    DriveApp.getRootFolder().removeFolder(studentFolder);//take student folder out of Google Drive

  }

 

}

 

 

Version C

//this function makes a doc for each student

//Student has no access to Doc

//full name in Col 1

function docMaker(){

  var ss = SpreadsheetApp.getActiveSpreadsheet();

  var sheet = ss.getSheets()[0];//get first sheet

  var last = sheet.getLastRow();//end of roster size

 

  sheet.getRange('B2').setValue('Doc Name');

  sheet.getRange('C2').setValue('Doc ID');

  sheet.getRange('D2').setValue('Doc URL');

 

  //prompt for Folder Name

 

  var ui = SpreadsheetApp.getUi();

  var ask = ui.prompt('What do you want to name the teacher folder? \nStudent Docs will go inside this folder.');

  var response = ask.getResponseText();

 

  //Create a teacher folder

 

  var tFolder = DriveApp.createFolder(response);

  var tFolderId = tFolder.getId();//ID to teacher folder

  var tFolderUrl = tFolder.getUrl();//URL to teacher folder

  sheet.getRange('A1').setValue('Teacher Folder');//put teacher folder info in row 1

  sheet.getRange('B1').setValue(response);

  sheet.getRange('C1').setValue(tFolderUrl);

  sheet.getRange('D1').setValue(tFolderId);

  sheet.getRange('E1').setValue(' ');

 

  //Student folder names

 

  var ask2 = ui.prompt('If you want any text to appear after the student name, enter is here (e.g. Observations).  Note: It can be blank');

  var response2 = ask2.getResponseText();

 

  //call the document to be copied

   

  Logger.log('last '+last);

  for(var i=3;i<last+1;i++){

   

    var student = sheet.getRange(i, 1).getValue();//get student name

    var folder = DocumentApp.create(student + ' '+response2);

    var sFolder = folder.getName();

    var sFolderId = folder.getId();

    var sFolderUrl = folder.getUrl();

    sheet.getRange(i,2).setValue(sFolder);

    sheet.getRange(i,3).setValue(sFolderId);

    sheet.getRange(i,4).setValue(sFolderUrl);

   

    //Add student folders to teacher folder

    var teacherFolder = DriveApp.getFolderById(tFolderId);

   

    var studentFolder = DriveApp.getFolderById(sFolderId);

   

    teacherFolder.addFolder(studentFolder);//put student folder in teacher folder

   

    DriveApp.getRootFolder().removeFolder(studentFolder);//take student folder out of Google Drive

  }

 

}

 

 

Version D

//this function makes a doc for each student

//gives each student view only access

//needs to include email address

//add info as per headers in Row 2

function docMaker(){

  var ss = SpreadsheetApp.getActiveSpreadsheet();

  var sheet = ss.getSheets()[0];//get first sheet

  var last = sheet.getLastRow();//end of roster size

 

  sheet.getRange('E2').setValue('Doc Name');

  sheet.getRange('F2').setValue('Doc ID');

  sheet.getRange('G2').setValue('Doc URL');

 

  //prompt for Folder Name

 

  var ui = SpreadsheetApp.getUi();

  var ask = ui.prompt('What do you want to name the teacher folder? \nStudent Docs will go inside this folder.');

  var response = ask.getResponseText();

 

  //Create a teacher folder

 

  var tFolder = DriveApp.createFolder(response);

  var tFolderId = tFolder.getId();//ID to teacher folder

  var tFolderUrl = tFolder.getUrl();//URL to teacher folder

  sheet.getRange('A1').setValue('Teacher Folder');//put teacher folder info in row 1

  sheet.getRange('B1').setValue(response);

  sheet.getRange('C1').setValue(tFolderUrl);

  sheet.getRange('D1').setValue(tFolderId);

  sheet.getRange('E1').setValue(' ');

 

  //Student folder names

 

  var ask2 = ui.prompt('If you want any text to appear after the student name, enter is here (e.g. Observations).  \nNote: It can be blank');

  var response2 = ask2.getResponseText();

 

  //call the document to be copied

     

  Logger.log('last '+last);

  for(var i=3;i<last+1;i++){

   

    var studetnNumber = sheet.getRange(i, 1).getValue();//get student number

    var studentFirst = sheet.getRange(i, 2).getValue();//get student first name

    var studentLast = sheet.getRange(i, 3).getValue();//get student last name

    var email = sheet.getRange(i,4).getValue();//get student email

    var folder = DocumentApp.create(studentLast + ", " + studentFirst +' '+response2);

    var sFolder = folder.getName();

    var sFolderId = folder.getId();

    var sFolderUrl = folder.getUrl();

    folder.addViewer(email)//give the student view only access to the Doc

    sheet.getRange(i,5).setValue(sFolder);

    sheet.getRange(i,6).setValue(sFolderId);

    sheet.getRange(i,7).setValue(sFolderUrl);

   

    //Add student folders to teacher folder

    var teacherFolder = DriveApp.getFolderById(tFolderId);

   

    var studentFolder = DriveApp.getFolderById(sFolderId);

   

    teacherFolder.addFolder(studentFolder);//put student folder in teacher folder

   

    DriveApp.getRootFolder().removeFolder(studentFolder);//take student folder out of Google Drive

  }

 

}

 Version E

//this function makes a doc for each student

//gives each student editable access

//needs to include email address

//add info as per headers in Row 2

function docMaker(){

  var ss = SpreadsheetApp.getActiveSpreadsheet();

  var sheet = ss.getSheets()[0];//get first sheet

  var last = sheet.getLastRow();//end of roster size

 

  sheet.getRange('E2').setValue('Doc Name');

  sheet.getRange('F2').setValue('Doc ID');

  sheet.getRange('G2').setValue('Doc URL');

 

  //prompt for Folder Name

 

  var ui = SpreadsheetApp.getUi();

  var ask = ui.prompt('What do you want to name the teacher folder? \nStudent Docs will go inside this folder.');

  var response = ask.getResponseText();

 

  //Create a teacher folder

 

  var tFolder = DriveApp.createFolder(response);

  var tFolderId = tFolder.getId();//ID to teacher folder

  var tFolderUrl = tFolder.getUrl();//URL to teacher folder

  sheet.getRange('A1').setValue('Teacher Folder');//put teacher folder info in row 1

  sheet.getRange('B1').setValue(response);

  sheet.getRange('C1').setValue(tFolderUrl);

  sheet.getRange('D1').setValue(tFolderId);

  sheet.getRange('E1').setValue(' ');

 

  //Student folder names

 

  var ask2 = ui.prompt('If you want any text to appear after the student name, enter is here (e.g. Observations).  \nNote: It can be blank');

  var response2 = ask2.getResponseText();

 

  //call the document to be copied

     Logger.log('last '+last);

  for(var i=3;i<last+1;i++){

   

    var studetnNumber = sheet.getRange(i, 1).getValue();//get student number

    var studentFirst = sheet.getRange(i, 2).getValue();//get student first name

    var studentLast = sheet.getRange(i, 3).getValue();//get student last name

    var email = sheet.getRange(i,4).getValue();//get student email

    var folder = DocumentApp.create(studentLast + ", " + studentFirst +' '+response2);

    var sFolder = folder.getName();

    var sFolderId = folder.getId();

    var sFolderUrl = folder.getUrl();

    folder.addEditor(email); //add student as an editor of the folder

    sheet.getRange(i,5).setValue(sFolder);

    sheet.getRange(i,6).setValue(sFolderId);

    sheet.getRange(i,7).setValue(sFolderUrl);

   

    //Add student folders to teacher folder

    var teacherFolder = DriveApp.getFolderById(tFolderId);

   

    var studentFolder = DriveApp.getFolderById(sFolderId);

   

    teacherFolder.addFolder(studentFolder);//put student folder in teacher folder

   

    DriveApp.getRootFolder().removeFolder(studentFolder);//take student folder out of Google Drive

  }

 

}


Version F

//this function makes a doc for each student

//gives each student editable access

//needs to include email address

//add info as per headers in Row 2

function docMaker(){

  var ss = SpreadsheetApp.getActiveSpreadsheet();

  var sheet = ss.getSheets()[0];//get first sheet

  var last = sheet.getLastRow();//end of roster size

 

  sheet.getRange('D2').setValue('Doc Name');

  sheet.getRange('E2').setValue('Doc ID');

  sheet.getRange('F2').setValue('Doc URL');

 

  //prompt for Folder Name

 

  var ui = SpreadsheetApp.getUi();

  var ask = ui.prompt('What do you want to name the teacher folder? \nStudent Docs will go inside this folder.');

  var response = ask.getResponseText();

 

  //Create a teacher folder

 

  var tFolder = DriveApp.createFolder(response);

  var tFolderId = tFolder.getId();//ID to teacher folder

  var tFolderUrl = tFolder.getUrl();//URL to teacher folder

  sheet.getRange('A1').setValue('Teacher Folder');//put teacher folder info in row 1

  sheet.getRange('B1').setValue(response);

  sheet.getRange('C1').setValue(tFolderUrl);

  sheet.getRange('D1').setValue(tFolderId);

  sheet.getRange('E1').setValue(' ');

 

  //Student folder names

 

  var ask2 = ui.prompt('If you want any text to appear after the student name, enter is here (e.g. Observations).  \Note: It can be blank');

  var response2 = ask2.getResponseText();

 

  //call the document to be copied

 

  Logger.log('last '+last);

  for(var i=3;i<last+1;i++){

   

    var studetnNumber = sheet.getRange(i, 1).getValue();//get student number

    var studentFirst = sheet.getRange(i, 2).getValue();//get student first name

    var studentLast = sheet.getRange(i, 3).getValue();//get student last name

    var folder = DocumentApp.create(studentLast + ", " + studentFirst +' '+response2);

    var sFolder = folder.getName();

    var sFolderId = folder.getId();

    var sFolderUrl = folder.getUrl();

    sheet.getRange(i,4).setValue(sFolder);

    sheet.getRange(i,5).setValue(sFolderId);

    sheet.getRange(i,6).setValue(sFolderUrl);

   

    //Add student folders to teacher folder

    var teacherFolder = DriveApp.getFolderById(tFolderId);

   

    var studentFolder = DriveApp.getFolderById(sFolderId);

   

    teacherFolder.addFolder(studentFolder);//put student folder in teacher folder

   

    DriveApp.getRootFolder().removeFolder(studentFolder);//take student folder out of Google Drive

  }

 

}