Hello stackoverflow向导我需要一些帮助。我试图从我的公司共享驱动器下载所有文件和文件夹。我还需要下载子文件夹及其文件,所有这些都必须导出到谷歌表。现在我有下面的代码只适用于一个文件夹,但是我们拥有数百个文件夹和子文件夹,它将永远需要我手工完成。如何修改它以实现我的目标?
// replace your-folder below with the folder for which you want a listing
function listFolderContents() {
var foldername = 'your-folder';
var folderlisting = 'listing of folder ' + foldername;
var folders = DriveApp.getFoldersByName(foldername)
var folder = folders.next();
var contents = folder.getFiles();
var ss = SpreadsheetApp.create(folderlisting);
var sheet = ss.getActiveSheet();
sheet.appendRow( ['name', 'link'] );
var file;
var name;
var link;
var row;
while(contents.hasNext()) {
file = contents.next();
name = file.getName();
link = file.getUrl();
sheet.appendRow( [name, link] );
}
};