google apps script - Use unique values from a column range -


i made script create folders , files in these specific folders. script works fine can't use unique values column range (the folders , files name of range - separated coma) - need a1 value in range name of first folder (and same name of files), a2 value name of second folder (and files), , on...

what can solve this?

function myfunction() {         var aa = spreadsheetapp.getactivesheet();     var data = aa.getdatarange().getvalues();      var pasta = driveapp.createfolder(data);     driveapp.getfolderbyid('0b1b9zgsfr8j0rw82ntrqejd5bmm').addfolder( pasta );     driveapp.getrootfolder().removefolder(pasta);      var doc = documentapp.create(data);     docfile = driveapp.getfilebyid( doc.getid() );     driveapp.getfolderbyid( pasta.getid() ).addfile( docfile );     driveapp.getrootfolder().removefile(docfile);      docsheet = driveapp.getfilebyid('1zspgqv5u9kvtu9h9kcwh9yutugtj8x9fjlke7_vdcws');     var dodo = docsheet.makecopy().setname(data);     driveapp.getfolderbyid( pasta.getid() ).addfile( dodo );     driveapp.getrootfolder().removefile(dodo); } 

you want along lines of

function myfunction() {       var aa = spreadsheetapp.getactivesheet();   var data = aa.getdatarange().getvalues();    data.map(function(row) {  // column     return row[0];   }).filter(function(x, i, s) { // if index smaller have duplicate     return s.indexof(x) === i;   }).foreach(function(name){      // create folder     var pasta = driveapp.createfolder(name);     driveapp.getfolderbyid('0b1b9zgsfr8j0rw82ntrqejd5bmm').addfolder(pasta);     driveapp.getrootfolder().removefolder(pasta);      // create doc var doc = documentapp.create(name);     docfile = driveapp.getfilebyid( doc.getid() );     driveapp.getfolderbyid(pasta.getid()).addfile(docfile);     driveapp.getrootfolder().removefile(docfile);      // copy docsheet     docsheet = driveapp.getfilebyid('1zspgqv5u9kvtu9h9kcwh9yutugtj8x9fjlke7_vdcws');     var dodo = docsheet.makecopy().setname(name);     driveapp.getfolderbyid(pasta.getid()).addfile(dodo);     driveapp.getrootfolder().removefile(dodo);   });     } 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -