Created
December 1, 2018 03:08
-
-
Save tuantranf/224547c521776e5475db75253eb0940b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// replace your-folder below with the folder for which you want a listing | |
function listFolderContents() { | |
var id = 'xxxxx'; | |
var folders = DriveApp.getFolderById(id).getFolders() | |
Logger.log(folders); | |
while (folders.hasNext()) { | |
var folder = folders.next(); | |
Logger.log(folder.getName()); | |
var contents = folder.getFiles(); | |
var folderlisting = 'listing of folder ' + folder.getName(); | |
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] ); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment