LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Tuesday, April 23, 2019

Googleドライブ内の特定のフォルダ内でファイルを探したい(スクリプトで)


ドライブ内で検索するのは searchFiles(params) のリファレンスにかかれていましたが、特定のフォルダ内で検索したくて書きました。



ちなみにドライブのUIで普通に探す場合は
https://support.google.com/drive/answer/2375114?hl=ja&co=GENIE.Platform%3DDesktop



コード.gs
function getFilesBySearch() {
  var folder = DriveApp.getFolderById("ID");
  var files = folder.searchFiles('title contains "タイトルの文字列の一部分"');
  while (files.hasNext()) {
    var file = files.next();
    Logger.log(file.getName());
  }
}



参考

Latest post

Extracting data from Google Sheets with regular expressions

Introduction Regular expressions are a powerful tool that can be used to extract data from text.  In Google Sheets, regular expressions ca...