Created
February 22, 2017 15:59
-
-
Save IanMcT/2534c40ab12b2d9b1739aa719d01f11b to your computer and use it in GitHub Desktop.
Google Script code for copying a file for every student in the class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myFunction() { | |
// Usercan copy the current file with a new name. | |
var ui = DocumentApp.getUi(); | |
var newFileName = ""; | |
while (newFileName != "Q"){ | |
if (newFileName != "Q") | |
{ | |
Logger.log('File name is not Q'); | |
}else | |
{ | |
Logger.log('File name is Q'); | |
} | |
var response = ui.prompt('File Copier', 'Type a new and click yes to copy the current file with that name', ui.ButtonSet.YES_NO); | |
// Process the user's response. | |
if (response.getSelectedButton() == ui.Button.YES) { | |
//copy file | |
// Get the document to which this script is bound. | |
var doc = DocumentApp.getActiveDocument(); | |
var destFolder = DriveApp.getFolderById(doc.getId()); | |
DriveApp.getFileById(doc.getId()).makeCopy(response.getResponseText()) | |
} | |
else if (response.getSelectedButton() == ui.Button.NO) { | |
newFileName = "Q"; | |
} else { | |
Logger.log('The user clicked the close button in the dialog\'s title bar.'); | |
newFileName = "Q"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment