I have two Google Drive accounts that I would like them to be synced automatically using Google Scripts.
I need the script to do the following:
I need the whole folder and files (in the source Google Drive account) to be synced to the destination Google Drive account once there are any changes (new/modified/deleted files/folders).
It should notify me by email once there is an action made.
Please help me figure how to start doing this script as I had this script collected from others that I found in this forum:
function copyfile() {
var sourceFolderName = "root";
var destinationFolderName = "Folder 2 ID";
var source_folder = DriveApp.getFoldersByName(sourceFolderName).next();
var files = source_folder.getFiles();
var dest_folder = DriveApp.getFoldersByName(destinationFolderName).next();
var destination_files = [];
var fileIterator = dest_folder.getFiles()
while (fileIterator.hasNext())
destination_files.push(fileIterator.next().getName());
while (files.hasNext()) {
var srcFile = files.next();
var newName = srcFile.getName();
if (destination_files.indexOf(newName) == -1) {
srcFile.makeCopy(dest_folder);
}
}
}