2
votes

Problem:- List all the files in google drive which were modified in last 24 hours.

Tried the following:- * Used DocsList API to get the files under a folder, based on the last modified time, able to identify the files which were modified.

Problems Facing:- There are many folders/sub folders in my drive, when am processing all the folders recursively script taking longer time and getting timed out.

Alternative:- In the Google Drive, there's a field called Activity, which will show the recent activity.

Is this possible to get the Activity from google drive using API(DocsList, GoogleDrive,other? If Yes, please let me know the details.

Also, if there are other solutions please let me know.

Thanks in adance...

2

2 Answers

2
votes

Check out the change feed: https://developers.google.com/drive/manage-changes

The is a part of the Drive SDK, which allows you to request all changes that have occurred since a particular change id.

2
votes

I realize this is an old question and I am not certain this was even possible when it was asked, but it is fairly straightforward with the DriveApp service now.

function listRecentFiles() {
  var ageInHours = 24;
  var targetDate = new Date;
  targetDate.setHours( targetDate.getHours() - ageInHours );
  var q = 'modifiedDate > "' + targetDate.toISOString() + '"';

  var files = DriveApp.searchFiles(q);

  while( files.hasNext() ) {
    var file = files.next();
    Logger.log(file.getName());
  }
}

Reference:

https://developers.google.com/apps-script/reference/drive/drive-app#searchFiles(String) https://developers.google.com/drive/web/search-parameters