How to completely copy a file in google drive via Apps Script? [duplicate]

How to perform a full copy of a file including all comments in Google Drive using Apps Script? The file to be copied can be a document, presentation, spreadsheet.

A simple way to copy a file using Apps Script using the makeCopy()
function.
enter image description here

Here’s a sample function you can use:

function copyToFolder(){
  var destinationFolderId = DriveApp.getFolderById("ID of destination folder")
  var file = DriveApp.getFileById("ID of file to Copy")
  file.makeCopy("New File Name" + file,destinationFolderId);
}

Leave a Comment