0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GAS: フォルダー内の Google Sheet の名前とIDを取得

Last updated at Posted at 2025-07-15

プログラム

list_google_sheets.gs
function list_google_sheets() {
  // フォルダIDを入力(URLの "folders/" の後ろにある文字列)
  let folderId = '1xNCydfWePqrzLEsvmYf20Ht9POXvgRf9';
  let folder = DriveApp.getFolderById(folderId);

  // 拡張子が .xlsx のファイルだけ取得
  let files = folder.getFilesByType(MimeType.GOOGLE_SHEETS);

Logger.log('*** start ***');
let str_out = '\n';


  while (files.hasNext()) {
    var file = files.next();
    Logger.log('Name: ' + file.getName() + ', ID: ' + file.getId());
    str_out += 'Name: ' + file.getName() + ', ID: ' + file.getId() + '\n';
  }

DriveApp.createFile('log_jul16_2025',str_out, MimeType.PLAIN_TEXT);
  Logger.log('*** end ***')
}

実行結果

gas01.png

保存したスクリプトは、こちらで見れます。

https://script.google.com/home

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?