How to Convert AppSheet Image URLs into Google Drive Viewable Links Using Apps Script?
AppSheet is a powerful no-code tool from Google that lets you build mobile and web apps using Google Sheets data. But if you’ve worked with AppSheet image fields, you’ve likely encountered this issue:
The image URL saved in your Google Sheet looks like this:
Items_Images/e4d92ee1.Photograph.113150.jpg
This isn’t a direct URL to the image. It’s a relative path stored by AppSheet, pointing to a file saved in a Google Drive folder. So if you try to view this in Google Sheets, dashboards, or embed it somewhere else — it won’t work directly.
In this blog, I’ll show you how to automatically convert these AppSheet image URLs into Google Drive viewable links using Google Apps Script — in just a few lines of code.
📌 Understanding the Problem
When AppSheet stores images:
- It saves them in a dedicated folder in your Google Drive.
- Instead of storing a shareable Google Drive URL, it stores a relative path like:
Items_Images/filename.jpg
This means:
- Your Google Sheet has the image file name, but not a direct URL.
- You can’t use this image in reports, PDFs, or even preview it easily.
✅ Our Goal
We want to:
- Read the
Photograph
column in the Google Sheet. - Detect if the entry is an AppSheet-style image path.
- Search for the file in Google Drive.
- Create a publicly viewable link (
https://drive.google.com/uc?export=view&id=...
) - Update the sheet with the new link.
🧠 Solution Using Google Apps Script
Here’s a full script that does this:
function convertAllAppSheetURLs() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const dataRange = sheet.getDataRange();
const data = dataRange.getValues();
const headers = data[0];
const photoColIndex = headers.indexOf("Photograph");
if (photoColIndex === -1) {
Logger.log("Photograph column not found");
return;
}
for (let i = 1; i < data.length; i++) {
const photoPath = data[i][photoColIndex];
if (typeof photoPath === 'string' && photoPath.includes("/") && !photoPath.includes("https://")) {
const fileName = photoPath.split('/').pop();
const folderName = photoPath.split('/')[0];
const folders = DriveApp.getFoldersByName(folderName);
if (folders.hasNext()) {
const folder = folders.next();
const files = folder.getFilesByName(fileName);
if (files.hasNext()) {
const file = files.next();
file.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
const fileId = file.getId();
const driveUrl = `https://drive.google.com/uc?export=view&id=${fileId}`;
sheet.getRange(i + 1, photoColIndex + 1).setValue(driveUrl);
} else {
Logger.log(`File not found: ${fileName}`);
}
} else {
Logger.log(`Folder not found: ${folderName}`);
}
}
}
}
🛠️ Step-by-Step: How to Use It
- Open your Google Sheet.
- Click Extensions → Apps Script.
- Paste the above code into the script editor.
- Save and click Run → convertAllAppSheetURLs.
- Grant permissions if prompted.
- Watch your sheet update with proper image URLs!
Example Output
Before:
Items_Images/e4d92ee1.Photograph.113150.jpg
After:
https://drive.google.com/uc?export=view&id=1a2b3c4d5e6f...
You can now:
- Embed this in documents
- Display images in dashboards
- Include in AppSheet PDFs or HTML reports
🔒 Manage Permissions
This script automatically sets file permissions to “Anyone with the link can view”, so make sure you’re not exposing sensitive content unintentionally. If you want tighter control, skip or modify the line:
file.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
🎯 Conclusion
AppSheet makes it easy to collect images, but working with those images outside AppSheet can be tricky. With this simple Google Apps Script, you can convert internal image paths into usable public URLs — unlocking better integrations, better PDFs, and better visibility.