-
-
Save alvnfaiz/1d4b98c5b722355ff6db29896ae37a6d to your computer and use it in GitHub Desktop.
List all files in a folder (Google Apps Script)
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
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