More from TechLever YouTube Channel
Level 1: Drive Image Importer
Import Drive images into Google Sheets with thumbnails
🎓 Beginner
⏱️ 2-3 minutes
Prerequisites
- • Basic JavaScript
- • Google Account
- • Google Sheets
You'll Learn
- ✓ Google Apps Script basics
- ✓ DriveApp and SpreadsheetApp services
- ✓ Working with Google Sheets programmatically
What You'll Build
- Google Apps Script that reads from a Drive folder
- Automatic thumbnail generation for images
- Data population in Google Sheets
Key Learning Areas
- Google Apps Script Setup: Create and run functions in Google Sheets
- Drive Folder Access: Access files using folder ID from DriveApp
- Sheet Manipulation: Clear sheets, set values, and format data programmatically
- Thumbnail Generation: Create Drive thumbnail URLs and embed with IMAGE function
Technical Skills
- Google Apps Script (server-side JavaScript for Google Workspace)
- DriveApp service (accessing Google Drive files and folders)
- SpreadsheetApp service (manipulating Google Sheets)
- Sheet ranges and data arrays
- File iteration and configuration reading
Implementation
/* global SpreadsheetApp, DriveApp */
function insertImages() {
var ss = SpreadsheetApp.getActiveSpreadsheet()
var configSheet = ss.getSheetByName('Config')
var folderId = configSheet.getRange('A1').getValue()
var activeSheet = ss.getActiveSheet()
insertFilesIntoSheet(folderId, activeSheet)
}
function insertFilesIntoSheet(folderId, sheet) {
var folder = DriveApp.getFolderById(folderId)
var files = folder.getFiles()
var rows = [['File Name', 'URL', 'Thumbnail']]
while (files.hasNext()) {
var file = files.next()
var fileId = file.getId()
var thumbnailUrl = 'https://drive.google.com/thumbnail?id=' + fileId + '&sz=200'
rows.push([file.getName().split('.')[0], thumbnailUrl, '=IMAGE("' + thumbnailUrl + '")'])
}
sheet.clear()
sheet.getRange(1, 1, rows.length, rows[0].length).setValues(rows)
}
Ready for the next level?
Continue your learning journey with the next level of this tutorial.
Next Level: Level2