Skip to content

Instantly share code, notes, and snippets.

@acurtis517
acurtis517 / appsScript_ListFilesFolders_ver.2.js
Created April 21, 2025 00:16 — forked from mesgarpour/appsScript_ListFilesFolders_ver.2.js
[Google Apps Script] List all files & folders in a Google Drive folder, & write into a speadsheet
/*
* Copyright 2017 Mohsen Mesgarpour
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@acurtis517
acurtis517 / submit.md
Created April 24, 2025 03:59 — forked from tanaikech/submit.md
Creating Tree Structure from Headings in Google Documents using Google Apps Script

Creating Tree Structure from Headings in Google Documents using Google Apps Script

Description

This is a Google Apps Script for creating the tree structure from headings in Google Documents.

Usage

@acurtis517
acurtis517 / submit.md
Created April 24, 2025 04:04 — forked from tanaikech/submit.md
Creating Google Document by Converting PDF and Image Files with OCR using Google Apps Script

Creating Google Document by Converting PDF and Image Files with OCR using Google Apps Script

This is a sample script for creating Google Document by converting PDF and image files with OCR using Google Apps Script.

Before you run this sample script, please install a GAS library of FetchApp.

function sample() {
  var fileId = "### fileId of PDF file and image files ###";
  var metadata = {
@acurtis517
acurtis517 / submit.md
Created April 24, 2025 15:48 — forked from tanaikech/submit.md
Report: Efficiently Creating Web Apps using a Google Apps Script library

Report: Efficiently Creating Web Apps using a Google Apps Script library

This is a sample script for efficiently creating Web Apps using a Google Apps Script library.

When a Google Apps Script library is used for creating Web Apps, the following advantage can be obtained.

  • The script of the client-side can be simpler. Because most scripts for constructing Web Apps are included in the Google Apps Script library.
  • When the script of Web Apps (In this case, the script of Google Apps Script library is modified.) is modified, the latest script is reflected in the Web Apps, immediately. Because when the Google Apps Script library is used as the latest version when the script of the library is modified, the client can use the latest script of the library, immediately. So, the downtime of Web Apps can be reduced.
    • By this, it is not required to manually reflect the latest version of the script to the Web Apps.
  • When you can change the script of Web Apps by changing the deployed version of the library.
@acurtis517
acurtis517 / submit.md
Created April 24, 2025 22:15 — forked from tanaikech/submit.md
Converting Many Files to Google Docs using Google Apps Script

Converting Many Files to Google Docs using Google Apps Script

This is a sample script for converting a lot of files to Google Docs (Spreadsheet, Document and Slides).

  • Batch request can be used for converting files. In this sample script, the files are converted using the batch request.
  • Batch request can request 100 API by one API call.
  • This sample script uses the fetchAll method. So even if there are over 100 files, this script can process them.

Sample script:

Before you run the script, please set the variables at main(). And, please enable Drive API at Advanced Google services.

@acurtis517
acurtis517 / Method1.gs
Created April 25, 2025 03:01 — forked from mhawksey/Method1.gs
Google Apps Script methods for generating Google My Drive report.
// @OnlyCurrentDoc
const FOLDER_ID = 'YOUR_FOLDER_ID'; // OR 'root' if you want your entire My Drive
/**
* Method One: Using built-in DriveApp / file iterator
*/
function generateFolderFilesDriveApp() {
try {
const folderId = FOLDER_ID;
const parentFolder = (folderId === 'root') ? DriveApp.getRootFolder() : DriveApp.getFolderById(folderId);
@acurtis517
acurtis517 / submit.md
Created April 26, 2025 03:48 — forked from tanaikech/submit.md
Upload Files to Google Drive using Javascript

Upload Files to Google Drive using Javascript

News

At October 11, 2019, I published a Javascript library to to run the resumable upload for Google Drive. When this is used, the large file can be uploaded. You can also use this js library.

Description

This is a sample script for uploading files to Google Drive using Javascript. The files are uploaded by Drive API v3. gapi.client.drive.files.create() can create an empty file on Google Drive. But it cannot directly upload files including contents. I think that this might not be able to upload files and metadata with the multipart/related, although this might be resolved by the future update. So now, as one of workarounds, I use using XMLHttpRequest.

  • This sample uses gapi.
  • Before you use this, please enable Drive API at API console and carr
@acurtis517
acurtis517 / gist:f6cfb9290a8a4c5a78e6f35432dcc0b4
Created April 26, 2025 04:01 — forked from mhawksey/gist:2252211
Google Apps Script to combine data from different sheets (used in http://mashe.hawksey.info/?p=13130)
function combineData(){
var doc = SpreadsheetApp.getActiveSpreadsheet();
var sheets = doc.getSheets(); // get all the sheets
var outSheet = doc.getSheetByName("combined"); // set where we want to write the results
for (i in sheets){ // loop across all the sheets
if (sheets[i].getSheetName().substring(0,9) == "followers"){ // if sheetname starts with 'follower' then
var target = sheets[i].getSheetName().substring(12); // extract users name for target column
var data = getRowsData(sheets[i]); // get extisting data from current sheet
for (j in data){
data[j]["target"] = target; // create a target column with the users name
@acurtis517
acurtis517 / submit.md
Created April 26, 2025 05:42 — forked from tanaikech/submit.md
A Versatile Approach to Uploading Files with Node.js: Integrating Gemini, Drive, YouTube, and Other APIs

A Versatile Approach to Uploading Files with Node.js: Integrating Gemini, Drive, YouTube, and Other APIs

Abstract

A script using resumable upload with file streams is proposed to enhance file handling within the Gemini Generative AI API for Node.js. This script allows uploading from web URLs and local storage, efficiently handles large files, and offers potential reusability with other Google APIs.

Description

The @google/generative-ai library provides a powerful way to interact with the Gemini Generative AI API using Node.js. This enables developers to programmatically generate creative text formats, translate languages, write different kinds of creative content, and answer your questions in an informative way, all powered by Gemini's advanced AI models. Ref

@acurtis517
acurtis517 / submit.md
Created April 26, 2025 05:48 — forked from tanaikech/submit.md
Gemini-Powered Dynamic Pseudo-RAG for Efficient Script Generation

Gemini-Powered Dynamic Pseudo-RAG for Efficient Script Generation

Abstract

This report presents a method to optimize AI-generated scripts for processing costs using Gemini and Google Apps Script. By incorporating external knowledge from sources like StackOverflow, we demonstrate the effective generation of efficient scripts that minimize overhead while maintaining desired outcomes. This approach can be considered a dynamic pseudo-RAG technique.

Introduction

The proliferation of generative AI, exemplified by Google Gemini, has led to a surge in AI-generated scripts. This trend is evident in the growing number of questions on platforms like StackOverflow that involve AI-generated scripts. While this indicates a significant improvement in AI performance, it's crucial to note that AI-generated scripts may not always be optimized for processing costs, especially when the prompt fails to provide sufficient context.