This simple script extracts images from a given Google Sheet into a specified folder on the user's Google Drive.
It is designed to parse a specific format in order to keep information about the image according to its position in the spreadsheet. See Usage below for more details.
This script works by using DocsServiceApp, a Google Scripts library by tanaikech. Please refer to that project's GitHub repository to read more about capabilities and limitations.
-
Install Node.js.
-
Install Google Clasp, preferably globally.
-
Clone repository into a local directory.
-
Recommended: Install Google Apps Script type definitions for Typescript into directory.
-
Use
clasp create --rootDir ./appsscript
-
Open your project in the browser with
clasp open
and install the DocsServiceApp library.
The format has a label/prompt in column A, and a corresponding image/response in column B
The starting row can vary (see below)
Define your parameters in appsscript/values.ts
// values
const ssID: string = SHEET_ID; //to get images from
const genFolderName: string = 'Sheet Image Evaluations'; // root folder
const evaluationName: string = "Cats"; // sub folder
const imageRange: number = 4; // number of prompts/images
const startRow: number = 1; // row where prompts/images start
const sheetName: string = "Sheet1"; // specify a sheet to get images from
The script creates the following folder path in Google Drive:
/rootDrive/genFolderName/evaluationName/{all image files}
Images are named after their corresponding prompt on the same row, with a prefix storing their position from top to bottom.