Aim of the puzzle: Use Apps Script to get a file from Drive and print its name.
Walk through of the solution: Every file in Drive has a unique id. An id is a long string of characters and numbers, like this:
.getName(), which returns the name of a file from Drive.
In the code that you start off with, the file with the id
id1 is retrieved using
DriveApp.getFileById(id1) and saved to the variable
file. Then, its name is stored in the
filename variable using
file.getName() and printed to the console.
To complete the puzzle, change the id inside the parentheses of
id2. This will retrieve a different file and print its name to the console.
Sample code solution:
let id1 = 'accb4372522af72303e7bcd67a8e953189205bb6728a'; let id2 = 'e514a7d3e2061ca9e33533074ded28a650a57cd24f04'; let file = DriveApp.getFileById(id2); let fileName = file.getName(); console.log(fileName);
Apps Script concepts: