Build a photo-gallery deck from a Drive folder
Drop every image in a Drive folder onto its own slide — for Northwind portfolio decks.
Published Aug 10, 2025
After every Northwind shoot, the team has a folder of finished images and a client who wants to see them in a tidy deck. Building that deck by hand — new slide, insert image, resize, caption, repeat — eats half an hour and nobody enjoys it.
This script does the whole thing from one folder. Point it at a Drive folder and a title, and it creates a fresh Slides deck with a title slide followed by one slide per image, each captioned with the file name. It is the quickest way to turn a pile of photos into a portfolio deck a client can flick through.
What you’ll need
- A Drive folder containing the images you want in the deck. Non-image files in the folder are skipped, so it does not matter if it also holds raw files or notes.
- The folder’s ID — the long string in its Drive URL after
/folders/. - Nothing else — the script creates a brand-new Slides deck each time it runs.
The script
// Slide layout constants. Slides measures everything in points;
// a default deck is 720 x 405 points.
const CAPTION_LEFT = 10; // Left edge of the caption text box.
const CAPTION_TOP = 350; // Near the bottom of the slide.
const CAPTION_WIDTH = 700; // Almost the full slide width.
const CAPTION_HEIGHT = 30; // A single line of caption text.
/**
* Builds a Slides deck with one slide per image in a Drive folder.
* @param {string} folderId - ID of the Drive folder of images.
* @param {string} deckTitle - Title for the deck and its first slide.
* @return {string} URL of the new deck.
*/
function buildGalleryDeck(folderId, deckTitle) {
// 1. Create the deck and set its built-in title slide.
const deck = SlidesApp.create(deckTitle);
deck.getSlides()[0]
.getPlaceholders()[0]
.asShape()
.getText()
.setText(deckTitle);
// 2. Walk every file in the folder.
const images = DriveApp.getFolderById(folderId).getFiles();
let count = 0;
while (images.hasNext()) {
const file = images.next();
// 3. Skip anything that is not an image (raw files, notes, PDFs).
if (!file.getMimeType().startsWith('image/')) continue;
// 4. Add a blank slide and drop the image onto it.
const slide = deck.appendSlide(SlidesApp.PredefinedLayout.BLANK);
slide.insertImage(file.getBlob());
// 5. Caption the slide with the file name.
slide.insertTextBox(
file.getName(), CAPTION_LEFT, CAPTION_TOP, CAPTION_WIDTH, CAPTION_HEIGHT);
count++;
}
Logger.log('Added ' + count + ' image slides to "' + deckTitle + '".');
return deck.getUrl();
}
How it works
SlidesApp.createmakes a new deck. Every new deck opens with a title slide, so the script grabs its first placeholder and sets the title text.DriveApp.getFolderById(folderId).getFiles()returns an iterator over every file in the folder. Thewhile (images.hasNext())loop walks it one file at a time — Drive does not load them all at once.- For each file it checks the MIME type. Anything that does not start with
image/is skipped, so stray PDFs or raw camera files do not become blank slides. - For a real image it appends a blank-layout slide and calls
insertImagewith the file’s blob, placing the picture on the slide. - It adds a small text box near the bottom holding the file name, so each slide is captioned without any manual typing.
- When the loop ends it logs how many slides it added and returns the deck’s URL, ready to share.
Example run
A folder holds harbour-01.jpg, harbour-02.jpg, a notes.txt, and
harbour-03.png. Running the script:
function run() {
const url = buildGalleryDeck('1abcFolderId', 'Riverside Shoot — June');
Logger.log(url);
}
produces a deck with four slides:
| Slide | Contents |
|---|---|
| 1 | Title: “Riverside Shoot — June” |
| 2 | harbour-01.jpg, captioned “harbour-01.jpg” |
| 3 | harbour-02.jpg, captioned “harbour-02.jpg” |
| 4 | harbour-03.png, captioned “harbour-03.png” |
The notes.txt file is skipped, and the log reads Added 3 image slides to "Riverside Shoot — June".
Run it
This is an on-demand job — you run it when a shoot is ready.
- In the Apps Script editor, edit the
runfunction above with the real folder ID and the deck title you want. - Select
runand click Run. - Approve the authorisation prompt the first time.
- Open the logged URL to view the finished deck.
Watch out for
insertImageplaces the picture at its natural size, which can overflow the slide for large photos. If your images run big, followinsertImagewith.setWidth()and.setHeight()(or centre it) to fit the slide.- Images are embedded as blobs, so the deck holds full copies. A folder of large photos makes a heavy file — resize images first if deck size matters.
- File-name captions are only as tidy as your file names.
IMG_4821.JPGis an ugly caption; rename files in Drive first, or strip the extension in code. - Folders with hundreds of images can hit the Apps Script six-minute execution limit. For very large galleries, split the folder or build the deck in batches.
getFiles()reads the folder only, not its subfolders. Images tucked inside subfolders are ignored.
Related
Extract all deck text into a sheet
Pull text out of every slide for review, translation, or copy-editing.
Updated Jan 4, 2026
Generate sales-enablement decks per segment
Tailor Northwind's messaging slides by audience segment — fintech, healthcare, retail.
Updated Dec 28, 2025
Insert chapter divider slides from an outline
Add section-break slides between chapters in a Northwind deck.
Updated Dec 21, 2025
Build a deck accessibility checker
Flag missing alt text, low contrast, and tiny fonts across a Northwind deck.
Updated Dec 14, 2025
Drive menu and price-list signage from a Sheet
Generate display slides for a Northwind venue — menus or price lists driven by a Sheet.
Updated Dec 7, 2025