GAS googleドライブ内の全てのファイル名を取得する

GAS googleドライブ内の全てのファイル名を取得する

GAS(Google Apps Script)で、googleドライブ内の全てのファイル名を取得する手順を記述してます。

環境

  • OS windows11 home
  • ブラウザ chrome 105.0.5195.102

全てのファイル名を取得

全てのファイル名を取得するには、「getFiles」を使用します。

DriveApp.getFiles;

実際に、取得するコードは以下となります。
※再帰的にも取得されます。

function myFunction() {

  const files = DriveApp.getFiles();
  
  while (files.hasNext()){ 
    Logger.log(files.next().getName());
  }

}

実行結果