GAS googleドライブ内のファイルの編集者を一覧取得する

GAS googleドライブ内のファイルの編集者を一覧取得する

GAS(Google Apps Script)で、googleドライブ内のファイルの編集者を一覧取得する手順を記述してます。「getEditors」で取得でき、「for-in」などを使用してループ処理で各要素を取得できます。

環境

  • OS windows11 home
  • ブラウザ chrome 107.0.5304.107

ファイルの編集者を一覧取得

ファイルの編集者を一覧取得するには、「getEditors」を使用します。

getEditors(file)

実際に、取得してみます。

function myFunction() {

  // idからファイルを取得
  let file = DriveApp.getFileById('xxxxxxxxxxxxxxxxxxx');

  let editors = file.getEditors();

  // ループ処理で全て取得
  for (let i in editors) {

    cosole.log( editors[i].getName() );

  }

}

※ファイルのidは、対象を「Ctrl」+「C」でURLのコピーをして「URL」から確認できます。