Skip to content

Instantly share code, notes, and snippets.

@mbutler
Forked from woodwardtw/listfiles_google_drive.js
Created November 17, 2018 05:47
Show Gist options
  • Save mbutler/aabcdeb576d84ebf00aed931d56e70fe to your computer and use it in GitHub Desktop.
Save mbutler/aabcdeb576d84ebf00aed931d56e70fe to your computer and use it in GitHub Desktop.
google script to list all subfolder content of a particular folder
function listFolders(folder) {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Name", "Folder", "Date", "Size", "URL", "Download", "Description", "Type"]);
var folder = DriveApp.getFolderById("0BxGcFSIReuGfOTJ0dTloY2xWS0E");
var subfolders = folder.getFolders();
while (subfolders.hasNext()) {
//Logger.log(folder);
var name = subfolders.next();
while (subfolders.hasNext()) {
//Logger.log(folder);
var name = subfolders.next();
var files = name.getFiles();
var cnt = 0;
var file;
while (files.hasNext()) {
var file = files.next();
cnt++;
Logger.log(file);
Logger.log(cnt);
data = [
file.getName(),
name, //folder name
file.getDateCreated(),
file.getSize(),
file.getUrl(),
"https://docs.google.com/uc?export=download&confirm=no_antivirus&id=" + file.getId(),
file.getDescription(),
file.getMimeType(),
];
sheet.appendRow(data);
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment