1

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.

  • Your task is quite easy to implement. Mission is possible. Mainly you have to use the [DocList](https://developers.google.com/apps-script/class_docslist) class. Have you tried to write the required script rather than googling? – megabyte1024 Aug 07 '12 at 07:00

1 Answers1

4

It's very simple:

DocsList.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId()).makeCopy(SpreadsheetApp.getActiveSpreadsheet().getName() + "_copy");
Tisho
  • 8,320
  • 6
  • 44
  • 52
louis
  • 353
  • 1
  • 3
  • 8
  • Awesome! Very clean piece of code. This is even simpler than I was hoping for. Now all I have to figure out is how to get the resulting file to save in my subfolder and I'm set. Thank you very much sir! – Alan McLaughlin Jr Aug 07 '12 at 21:45
  • And I did! Works like a charm. Couldn't have done it without the help. Thanks again very much. You just saved me hours of pulling hair. Mostly mine. ;) – Alan McLaughlin Jr Aug 07 '12 at 22:52
  • DocsList has been deprecated: https://developers.google.com/apps-script/guides/support/sunset. Service no longer functions. – karel Oct 20 '21 at 08:01