Skip to content

Instantly share code, notes, and snippets.

@jargetz
jargetz / get_file.gs
Last active August 14, 2020 17:41
Google Apps Script: Utility Functions 1) Match Columns by Name, 2) URL Obfuscate String
// Google Apps Script: Get Target File through Google Drive by ID, open as a spreadsheet.
/** Find a file in Google Drive by ID.
* fileID - fileID, which you can get from the ID section of the file URL
* return the file opened as a Spreadsheet
*/
function getSpreadsheetFromFileId(fileID) {
var file = DriveApp.getFileById(fileID);
if (!file) {
throw new Error("Critical file missing for script to work");