-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistfiles
More file actions
40 lines (35 loc) · 1.01 KB
/
listfiles
File metadata and controls
40 lines (35 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function onOpen() {
// Add Menu Item in Spreadsheet
SpreadsheetApp.getUi().createMenu("South Pole Function")
.addItem("List all consultancies folder", "listFiles")
.addToUi()
}
function listFiles() {
var ss = SpreadsheetApp.getActive();
// In which folder is this file?
var ssId = ss.getId();
var thisfile = DriveApp.getFileById(ssId);
var fold = thisfile.getParents();
if (fold.hasNext())
var folder = fold.next();
// Initialize the sheet
var sheet = ss.getActiveSheet();
sheet.clear()
// Insert Header
sheet.appendRow(["FileName","FileID", "DownloadUrl", "Size", "Url", "DateCreated", "LastUpdated", "Owner"]);
// Populate the sheet with Names, Id, end other attributes
var files = folder.getFiles();
while (files.hasNext()) {
var file = files.next();
sheet.appendRow([
file.getName(),
file.getId(),
file.getDownloadUrl(),
file.getSize(),
file.getUrl(),
file.getDateCreated(),
file.getLastUpdated(),
file.getOwner()
]);
}
}