LoginSignup
4
1

More than 5 years have passed since last update.

Google App ScriptでDriveにあるファイルの最終更新者を取得する

Posted at

Google Driveのファイルを更新した日時はわかるが更新者がわからない。
DriveApp.getEditors()はファイルの編集者リストを取得できるだけで、更新した人ではない。
他にもユーザーを取得できるAPIがありますが、どれも更新者ではないので調べました。

Advanced Google ServiceのDriveAPIを使う

Resources > Advanced Google services

img1.png

Drive APIを有効にする

img2.png

Drive.Filesから指定したファイルの最終更新者を取得する

sample.gs
...
//最終更新者の名前を取得
Logger.log("name:" + Drive.Files.get(file.getId()).lastModifyingUserName);
//ユーザーから取得
Logger.log("name:" + Drive.Files.get(file.getId()).lastModifyingUser.displayName);
...

FilesのAPIリファレンスはこちら。
https://developers.google.com/drive/v2/reference/files
他にもDriveAppでは取得できなかった色々な情報が取得できます。
ファイルの更新確認などを自動化したいときに使えそうです。


以上。

4
1
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
4
1