nahaku
Board Regular
- Joined
- Mar 19, 2020
- Messages
- 106
- Office Version
- 365
- 2019
- Platform
- Windows
Hello, I am using google sheet to record time spent on task, I also have script what will make a backup of it at night.
I would like to make it automatically either clear certain cells or return it the the default, Clean state only with my functions...
Is there some script or another options? this is script I am using for making automatic backup:
function makeCopy() {
var timeZone = Session.getScriptTimeZone();
// generates the timestamp and stores in variable formattedDate as year-month-date hour-minute-second
var formattedDate = Utilities.formatDate(new Date(), timeZone , "dd.MM.yyyy ");
// gets the name of the original file and appends the word "copy" followed by the timestamp stored in formattedDate
var name = formattedDate + SpreadsheetApp.getActiveSpreadsheet().getName();
// gets the destination folder by their ID. REPLACE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx with your folder's ID that you can get by opening the folder in Google Drive and checking the URL in the browser's address bar
var destination = DriveApp.getFolderById("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
// gets the current Google Sheet file
var file = DriveApp.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId())
// makes copy of "file" with "name" at the "destination"
file.makeCopy(name, destination);
}
I would like to make it automatically either clear certain cells or return it the the default, Clean state only with my functions...
Is there some script or another options? this is script I am using for making automatic backup:
function makeCopy() {
var timeZone = Session.getScriptTimeZone();
// generates the timestamp and stores in variable formattedDate as year-month-date hour-minute-second
var formattedDate = Utilities.formatDate(new Date(), timeZone , "dd.MM.yyyy ");
// gets the name of the original file and appends the word "copy" followed by the timestamp stored in formattedDate
var name = formattedDate + SpreadsheetApp.getActiveSpreadsheet().getName();
// gets the destination folder by their ID. REPLACE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx with your folder's ID that you can get by opening the folder in Google Drive and checking the URL in the browser's address bar
var destination = DriveApp.getFolderById("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
// gets the current Google Sheet file
var file = DriveApp.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId())
// makes copy of "file" with "name" at the "destination"
file.makeCopy(name, destination);
}