How do I script making a backup copy of a spreadsh

2019-08-07 01:04发布

问题:

I've got a spreadsheet that I update regularly and I need to make a time-stamped copy of it each time I do for historical data tracking purposes. I have a folder that I save the copies to on my Google Drive. Doing this manually has become rather cumbersome over time.

I'd like to form a script that would make a copy of my spreadsheet with the current time and date in the spreadsheet name and save it to my archive folder. I've spent the last few hours dinking around with and googling code that looked like it might do something similar but haven't managed anything substantial.

Any helpful pointers would be greatly appreciated.

Thanks.

回答1:

It's very simple:

DocsList.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId()).makeCopy(SpreadsheetApp.getActiveSpreadsheet().getName() + "_copy");