Skip to content

Instantly share code, notes, and snippets.

@jrichardsz
Forked from hubgit/list-files-in-folder.js
Created March 9, 2021 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrichardsz/13d84b1974a93567430a23b4ff1fdac3 to your computer and use it in GitHub Desktop.
Save jrichardsz/13d84b1974a93567430a23b4ff1fdac3 to your computer and use it in GitHub Desktop.
List all files in a folder (Google Apps Script)
function listFilesInFolder() {
var folder = DocsList.getFolder("Maudesley Debates");
var contents = folder.getFiles();
var file;
var data;
var sheet = SpreadsheetApp.getActiveSheet();
sheet.clear();
sheet.appendRow(["Name", "Date", "Size", "URL", "Download", "Description", "Type"]);
for (var i = 0; i < contents.length; i++) {
file = contents[i];
if (file.getFileType() == "SPREADSHEET") {
continue;
}
data = [
file.getName(),
file.getDateCreated(),
file.getSize(),
file.getUrl(),
"https://docs.google.com/uc?export=download&confirm=no_antivirus&id=" + file.getId(),
file.getDescription(),
"audio/mp3"
];
sheet.appendRow(data);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment