For my work, each time we bring on a new client we need to create a new folder structure in google drive (the same structure for every account) and in one folder we generate a copy of a google sheet that we have. This is rather time consuming, so was hoping there was a way to easily duplicate a google drive folder structure and have it make a copy of the google sheet that we include in one of the folders.
The perfect result would be to easily copy/duplicate an exact folder structure (obviously renaming it for the client) and then have the folder have the copy of the google sheet in the correct folder already
function createClientAccountFolder(brandName) {
//var brandName=brandName || 'BrandName';
var Template1=DriveApp.getFileById('TemplateId');//You need to add the id of your template here
var acctRoot=DriveApp.getFolderById('Accounts Root Folder Id');//you need to add the id of the root accounts folder here
if(brandName) {
var mainFldr=acctRoot.createFolder(Utilities.formatString('MainFolder-%s',brandName));
var liveFldr=mainFldr.createFolder(Utilities.formatString('%s-Live',brandName));
var editedFldr=mainFldr.createFolder(Utilities.formatString('%s-Edited',brandName));
var imgsFldr=liveFldr.createFolder('Images');
imgsFldr.createFolder('Ecommerce');
imgsFldr.createFolder('LifeStyles');
imgsFldr.createFolder('Model');
Template1.makeCopy(liveFldr);
}else{
SpreadsheetApp.getUi().alert('No Brand Name Specified')
}
}
You could enhance this script with a dialog that allows you to select different folders and possibly even add additional root account folders and the same with templates. But that is considerably more involved than what you have now.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments