-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistid
34 lines (29 loc) · 832 Bytes
/
listid
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
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(["FolderName","FolderID"]);
// Populate the sheet with Names, Id, end other attributes
var folders = folder.getFolders();
while (folders.hasNext()) {
var folder = folders.next();
sheet.appendRow([
folder.getName(),
folder.getId(),
]);
}
}