Skip to content

Instantly share code, notes, and snippets.

function createSheets() {
try {
// log event
logEvent("Starting 'createSheets' Function");
// get the 'Welcome' Sheet
/*
Global Variables that may need to be tweaked and are easier to access by placing here.
*/
// Maximum runtime of script in minutes to prevent timeout (5 minutes 30 seconds)
var maxRuntime = 5.5 * 60 * 1000;
/*
/*
The following Google Apps Script is designed to loop through a folder of CSV files in Google Drive, extract the data, create a Google Sheet file per CSV, and insert the data into specific rows/columns.
*/
function createSheets() {
// get template Google Sheet for copying
var templateSheet = DriveApp.getFileById('1Rj-TGRW01kx7TEVU-nXywn0yJ1GC96pgegWnuJ0Vtag');
@aplater
aplater / submit.md
Created June 15, 2021 12:11 — forked from tanaikech/submit.md
Request of multipart/form-data with Simple Request Body using Google Apps Script

Request of multipart/form-data with Simple Request Body using Google Apps Script

This is a sample script of the request of multipart/form-data with a simple request body using Google Apps Script. I hope that the users will easy to use Class UrlFetchApp by this report.

This report is the updated post of "Multipart-POST Request Using Google Apps Script".

Description

I had already reported about this at this report. In that case, it was required to create a bit complicated request body to request multipart/form-data. Today, by a comment, I could notice the sample script of Class UrlFetchApp in the official document had been updated. By this, I thought that multipart/form-data

@aplater
aplater / submit.md
Created May 4, 2021 22:11 — forked from tanaikech/submit.md
Uploading Local Files to Google Drive without Authorization using HTML Form

Uploading Local Files to Google Drive without Authorization using HTML Form

This is a sample script for uploading local file to Google Drive without the authorization using HTML form. A selected file in your local PC using HTML form is uploaded to Google Drive and saved to Google Drive.

When you use this, at first, please deploy Web Apps. The script is doPost() of following scripts.

Script : Google Apps Script

function doPost(e) {
 var data = Utilities.base64Decode(e.parameters.data);
@aplater
aplater / submit.md
Created May 4, 2021 22:10 — forked from tanaikech/submit.md
Enhanced makeCopy() using Google Apps Script

Enhanced makeCopy() using Google Apps Script

Overview

This is sample scripts for copying files to a specific folder in Google Drive using Google Apps Script (GAS).

Description

When the files in Google Drive are copied to a specific folder using GAS, most users will use makeCopy(destination). When the files are copied using makeCopy(), you might have already noticed that only the standalone projects cannot be copied to the specific folder. They are copied to the root folder (My Drive). Also this situation can be also seen even when "copy" of Drive API v2 and v3 is used. I think that this might be a bug. So I would like to introduce 2 sample scripts as the workaround. In the workaround, it uses Drive API.

Sample script 1

This sample is very simple.

@aplater
aplater / submit.md
Created May 4, 2021 22:08 — forked from tanaikech/submit.md
Changing Font of Selected Text to 'Google Sans' on Google Document using Google Apps Script

Changing Font of Selected Text to 'Google Sans' on Google Document using Google Apps Script

This is a sample script for changing the font of selected text to Google Sans on Google Document using Google Apps Script.

Sample script

Please copy and paste the following script to the script editor of Google Document And, when you use this script, please select a text in Google Document and run the script. By this, the font of selected text is changed to Google Sans.

/*
Function to get existing Group Members. Their email address and role.
Paste results into a Google Sheet.
*/
function getGroupMembers() {
// create empty array to push members details into
var memberDetails = [];
@aplater
aplater / Apps Script pdfToText utility.md
Created February 2, 2021 17:56 — forked from mogsdad/Apps Script pdfToText utility.md
For http://stackoverflow.com/questions/26613809, a question about getting pdf attachments in gmail as text. I got a little carried away - this does much more than asked.

Google Apps Script pdfToText Utility#

This is a helper function that will convert a given PDF file blob into text, as well as offering options to save the original PDF, intermediate Google Doc, and/or final plain text files. Additionally, the language used for Optical Character Recognition (OCR) may be specified, defaulting to 'en' (English).

Note: Updated 12 May 2015 due to deprecation of DocsList. Thanks to Bruce McPherson for the getDriveFolderFromPath() utility.

    // Start with a Blob object
    var blob = gmailAttchment.getAs(MimeType.PDF);
    
function getSaveLocation() {
// get spreadsheet
var ss = SpreadsheetApp.getActiveSpreadsheet();
// get Config sheet
var configSheet = ss.getSheetByName('Config');
// get Red Google Drive folder Id
var redFolderId = configSheet.getRange(3, 2).getValue();