Skip to content

Instantly share code, notes, and snippets.

@alvnfaiz
Forked from hubgit/list-files-in-folder.js
Created August 12, 2019 09:09
Show Gist options
  • Save alvnfaiz/1d4b98c5b722355ff6db29896ae37a6d to your computer and use it in GitHub Desktop.
Save alvnfaiz/1d4b98c5b722355ff6db29896ae37a6d 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