Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
script to take text from a google spreadsheet and save it as the description on a pdf in google drive
this script relies on a spreadsheet being called "test desc" and a pdf being called "test.pdf"
there needs to be a description in cell A1 of "test desc"
function setNewDescription(file_id,description){
var file_by_id = DriveApp.getFileById(file_id);
function getDescriptionFromSpreadsheet() {
Logger.log('load file');
var files = DriveApp.getFilesByName('test desc');
while (files.hasNext()) {
var spreadsheet =;
var sheet = spreadsheet.getSheets()[0];
// only after 1 file
var range = sheet.getRange("A1");
// The row and column here are relative to the range
// getCell(1,1) in this code returns the cell at B2, B2
var cell = range.getCell(1, 1);
var description = cell.getValue()
Logger.log('Cell value: ', description);
var files = DriveApp.getFilesByName('test.pdf');
while (files.hasNext()) {
var file =;
var file_id = file.getId();
setNewDescription( file_id, description );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.