google apps script - moving folders in drive using sheet -
back on seemingly impossible task. apparently people in office can't move folders around drive, task automate moving process. can see in sheet (link below) have setup routing system.
https://drive.google.com/file/d/0b2lmfutaxagkn1vhqlphofeynvk/view?usp=sharing
i have criteria, such name of folder, folder should in, , folder needs moved to. basically, i'm trying find script following things:
1) works when button selected in google sheet 2) moves folder in drive folder folder b. 3) using cell references.
don't know how find folder id, wouldn't folder moved change based on spreadsheet criteria. , can't use outside program it's on government system. ideas? have great piece of script, doesn't seem work using cell references.
function copyandmove(file,folder){ var newfile=file.makecopy('copy of '+file.getname(d9)); newfile.addtofolder(b1);// newfile.removefromfolder(docslist.getrootfolder());}
any appreciated!
to value in cell have use format below
var ss = spreadsheetapp.getactivespreadsheet(); var sheet = ss.getsheets()[0]; // first argument row, second column. 1,2 returns value in b1 var range = sheet.getrange(1, 1); var value = range.getvalue();
so final code be
function copyandmove() { var ss = spreadsheetapp.getactivespreadsheet(); var sheet = ss.getsheets()[0]; // first argument row, second column. 9,4 returns value in d9 var d9 = sheet.getrange(9, 4).getvalue(); var b1 = sheet.getrange(1, 2).getvalue(); var file = driveapp.getfilesbyname(d9).next(); var folder = driveapp.getfoldersbyname(b1).next(); var newfile = file.makecopy('copy of '+ d9, folder); file.settrashed(true); }
i'm not sure wanted newfile.removefromfolder(docslist.getrootfolder());
if wanted delete original file last line of function that.
Comments
Post a Comment