-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathlistFoldersEditDocs.gs
85 lines (57 loc) · 1.38 KB
/
listFoldersEditDocs.gs
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
function folderTree() {
var pf = DriveApp.getRootFolder();
getFolders(pf);
}
function getFolders(parent) {
var s = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var childFolders = parent.getFolders();
while (childFolders.hasNext()) {
var ch = childFolders.next();
var f = ch.getFiles(); var c = 0;
while (f.hasNext()){f.next();c++;}
var arr = [ch.getName(), ch.getUrl(), c];
s.appendRow(arr);
getFolders(ch);
}
}
function folderTree() {
var pf = DriveApp.getRootFolder();
getFolders(pf);
}
function getFolders(parent) {
var cf = parent.getFolders();
while (cf.hasNext()) {
var ch = cf.next();
var f = ch.getFiles();
var c = 0;
while (f.hasNext()){
var no = f.next();
try{
no.addEditor('[email protected]');
// no.setOwner('[email protected]')
c++;
} catch(e){continue;}
}
getFolders(ch);
}
}
function folderTree() {
var pf = DriveApp.getFolderById('ID');
getFolders(pf);
}
function getFolders(parent) {
var cf = parent.getFolders();
while (cf.hasNext()) {
var ch = cf.next();
var f = ch.getFiles();
var c = 0;
while (f.hasNext()){
var no = f.next();
try{
no.makeCopy(no.getName());
c++;
} catch(e){continue;}
}
getFolders(ch);
}
}