1
function copyFolderContents_(source, target) {
  // Iterate files in source folder
  const filesIterator = source.getFiles()
  while (filesIterator.hasNext()) {
    const file = filesIterator.next()

    // Make a copy of the file keeping the same name
    file.makeCopy(file.getName(), target)
  }
}

const toCopy = DriveApp.getFolderById('')
const copyInto = DriveApp.getFolderById('')
const newFolder = copyInto.createFolder(toCopy.getName())
copyFolderContents_(toCopy, newFolder)

Is it possible to let this run in my local machine? The API seems to be just controlling how the app script runs instead of letting you run the getFolderById makeCopy functions.

1

1 Answer 1

2

No, Apps Script is run in google cloud servers, so you cannot run it directly in your local machine by default. Alternatively, you can access the functionality via APIs.

Basically, getFolderById and makeCopy are just wrappers for specific Drive APIs for it to be used easily on Apps Script.

To do the same thing above, you can use a combination of Files: list and Files: copy

Check API Reference for more info.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for letting me know that makeCopy is also a wrapper

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.