Aim of the puzzle: Use Apps Script to rename a file from Drive.
Walk through of the solution: Apps Script has custom code functions that connect to Drive. One example is
.setName(), which sets the name of a file from Drive. For example,
myFile.setName('List of Lizards') sets the name of
List of Lizards.
To complete the puzzle, change the string that’s inside the parentheses of
file.setName() from ‘Inventory of Iguanas’ to a different string. Then, create a new variable called
newName that stores the new name of the file using
file.getName(). Finally, print
newName to the console.
Sample code solution:
let id = '4FTT3tZLKLxIJhBNdyDCGc1rYJLUV8kQ4c4aodAZx8pE'; let file = DriveApp.getFileById(id); let oldName = file.getName(); console.log(oldName); file.setName( 'List of Lizards'); let newName = file.getName(); console.log(newName);
Apps Script concepts: