メインコンテンツにスキップ

FilesApp

FilesApp is a GAS library for retrieving file and folder list in Google Drive using Google Apps Script (GAS). Also this can create a tree from all files and folders in Google Drive.

AI Summary

FilesApp

A Google Apps Script library that quickly retrieves file and folder lists or tree structures from Google Drive.

Target Users

Beginner-to-intermediate GAS developers building in-house tools who need hierarchical Drive file inventories for asset management or backups.

Problems Solved

Directly using the Drive API requires repetitive implementation of recursive folder traversal, field selection and shared-drive handling.

Tags

Main Features

1
One-liner recursive listing

Calling createTree() or getAllInFolder() returns every file and folder under a given ID as a hierarchical or flat list without manual recursion.

2
Supports fields and MIME type filters

Pass a Drive-API-style fields string and a MIME type array to limit metadata and reduce payload and runtime.

3
Works with Shared Drives & Service Accounts

An optional accessToken argument lets the same API list content in shared drives or a service account’s Drive.

Usage Examples

Retrieve and log the entire Drive file tree

function logDriveTree() {
  // Using "root" lists everything in the user’s My Drive and shared drives
  const tree = FilesApp.createTree('root', null, 'files(id,name)');
  // Print the result as a JSON string
  Logger.log(JSON.stringify(tree));
}

Run the snippet in the Apps Script editor to obtain a JSON tree of every folder and file in your Drive.