【问题标题】:Save all (non gdoc) revisions automatically自动保存所有(非 gdoc)修订
【发布时间】:2016-12-06 10:38:24
【问题描述】:

我想将我的 pdf、照片和其他非 GDoc 文件的所有修订保存在我的 Google 云端硬盘上。为此,我想使用 Google Apps 脚本。

那么我怎样才能获得所有的文件及其修订版

【问题讨论】:

    标签: google-apps-script google-drive-api


    【解决方案1】:

    如果您从 Resources > Advanced Google Services 启用 Drive API,则可以使用 API 的 revisions 部分。例如:

    var fileId = '<...id...>';
    
    // Retrieve list of revisions - specify that the modifiedDate and download
    // URL are required.
    var response = Drive.Revisions.list(fileId, {fields:'items(downloadUrl,modifiedDate)'});
    var revisions = JSON.parse(response);
    
    var items = revisions.items;
    
    // e.g. Inspect first item
    var firstItem = items[0];
    Logger.log(firstItem.downloadUrl);
    Logger.log(firstItem.modifiedDate);
    
    /*
    https://...etc
    2016-11-28T21:58:56.650Z
    */
    

    【讨论】:

    • 感谢您的回答。但是如何从每个文件中获取所有 ID?
    • 我不能指定每个 ID(我有 100.000 个文件并且还在计数)
    猜你喜欢
    • 1970-01-01
    • 2012-12-22
    • 1970-01-01
    • 1970-01-01
    • 2012-08-27
    • 2021-02-26
    • 1970-01-01
    • 1970-01-01
    • 2015-12-30
    相关资源
    最近更新 更多