How do I copy & move a file to a folder in Google Apps Script?

google-apps-script, move

Solution

In the new version of google apps script all you need to acheive your task is the following:

file.makeCopy("new name", folder);

Problem

Is there a way to copy and rename a file and move that copy to a particular folder without having a second copy in the root folder? I have used combinations of copy, rename, move in different order, but each time, I still end up with a copy of the renamed file the root drive. Is this by default? It is annoying to say the least.

Original source