2016-10-03 132 views
0

我的問題很簡單,並在標題中進行了描述。Google Drive API v2 - 列出所有標籤/限制= false的文件

我想在App Script中編寫一個腳本,它將搜索並列出我的驅動器(文件夾和子文件夾)中標籤/限制爲false的所有文件。

我可以獲取所有文件並逐個檢查,但這是非常耗時的腳本。

預先感謝您。

UPDATE:

更具體我使用腳本編輯器在谷歌電子表格。 我已經在腳本編輯器中啓用了Drive API,以防我需要它。

我用它來查找文件,在一個小時前修改日期是下面一個簡單的搜索:

var today  = new Date(); 
var oneHourAgo = new Date(today.getTime() - 1 * 1 * 60 * 60 * 1000); 
var startTime = oneHourAgo.toISOString(); 
var search = '(trashed = true or trashed = false) and (modifiedDate > "' + startTime + '")'; 
var files = DriveApp.searchFiles(search); 

現在,我想搜索所有的文件在驅動器具有label.restricted財產等於假。

+0

你試過了什麼?還有類似的問題可能會讓你大部分出現:[如何使用GAS在Google雲端硬盤中列出主文件夾及其所有子文件夾中的所有文件(或僅限某些類型的文件)](http:// stackoverflow。 com/questions/22841016),[列出文件夾中的所有文件,包括子文件夾中的文件](http://stackoverflow.com/questions/23750101/)和其他文件。此外,你不清楚你問的是什麼技術; Google Apps腳本和Google Drive API不是同一回事。 – Mogsdad

+0

這可能有所幫助:https://developers.google.com/apps-script/reference/drive/drive-app#searchFiles(String) –

+0

我更新了我的帖子,以便更具體。 –

回答

0

如果您使用Advanced Drive Services,則可以在Apps腳本中使用。

The advanced Drive service allows you to use the Google Drive web API in Apps Script. Much like Apps Script's built-in Drive service , this API allows scripts to create, find, and modify files and folders in Google Drive.

Drive.Files.list({'labels': {'restricted': true}}, fileId); 

指出,這一定是enabled before use

+0

嗨,這個腳本不適合我想做的事情。 給予fileId就像是要求獲取單個文件的信息。 –

相關問題