Google云端硬盘中的搜索脚本

时间:2017-02-09 13:58:44

标签: javascript google-chrome google-apps-script

我有一个脚本应该搜索Google云端硬盘中的所有文件。我将该脚本实施到了一个Google网站页面中。该脚本仅适用于根文件夹中的文件,但不适用于子文件夹中的文件。任何帮助赞赏。谢谢

这是当前的脚本:

function doGet(e) {
  var results = DriveApp.getFolderById('yourGoogleDriveId').searchFiles('fullText contains "' + e.parameter.q + '"');
  var output = HtmlService.createHtmlOutput('Results: <br /><br /><ul>');
  while (results.hasNext()) {
    var file = results.next();
    output.append('<li><a href="' + file.getUrl() + '">' + file.getName() + '</a></li>');
  }
  output.append('</ul>');
  return output;
}

1 个答案:

答案 0 :(得分:2)

正如@Cesar所提到的,DriveApp.searchFiles()应为DriveApp。两个类FoldersearchFiles()都有modifedDate方法,但只有前一个搜索递归。阅读文件。

我复制了你的代码并对其进行了测试(public void read(View v) { Cursor c = dBase.query("employee", null, "id=?", new String[]{ET1.getText().toString()}, null, null, null); while (c.moveToNext()) { Toast.makeText(getApplicationContext(), c.getInt(0) + "\n" + c.getString(1) + "\n" + c.getString(2) + "\n" + c.getString(3), Toast.LENGTH_LONG).show(); } ET1.setText("" + c.getInt(0)); ET2.setText("" + c.getString(1)); ET3.setText("" + c.getString(2)); ET4.setText("" + c.getString(3)); Intent i = new Intent(this, AnotherActivity.class); i.putExtra("1", ""); i.putExtra("2", ""); i.putExtra("3", ""); i.putExtra("4", ""); startActivity(i); /*write this Code in another activity after SetContentView(); to display data */ Log.e("1", getIntent().getStringExtra("1")); Log.e("2", getIntent().getStringExtra("2")); Log.e("3", getIntent().getStringExtra("3")); Log.e("4", getIntent().getStringExtra("4")); } 加快了速度)并且它运行良好。

相关问题