I'm quite new to Google Apps Script and I was wondering if it is possible to create a script which duplicates a template site and 'numbers' the new one's Title, Name, etc..
Here's what I'd want it to do:
So far I came up with this very simple copying script that is giving me an error when debugging and creates a blank "site0001" site
function CopySite() {
var siteCopy = SitesApp.copySite("mydomain.com", "site0000", "site0000",
//I have no idea what to put here//)
var site = SitesApp.createSite("mydomain.com", "site0001",
"site0001", "Site 0001")
}
.copySite()
creates the new site. You don't need to use .createSite()
afterwards. So, if you already have a 'site0000' at 'mydomain.com' and just want to copy it calling the new one 'site0001', try this
function copySite(){
var site = SitesApp.getSite('mydomain.com', 'site0000'); //find the site to copy
var newSite = SitesApp.copySite('mydomain.com', 'site0001', 'Site 0001', 'Site description', site); //create the new site
}
Then you can do what you like with newSite
.
You'll probably want to use variables for the new sites' names, etc. if you are going to be creating multiple of them.