I have a file by a specific name which it is not taking. Can you suggest? I want it to be a named file in the drive which should be moved to the folder. My Code :
function MoveFiles(){
var files = DriveApp.getFilesByName("Sampling Report-selected");
while (files.hasNext()) {
var file = files.next();
var destination = DriveApp.getFolderById("1-dh-xfZZdfnMOlPasy_yoJBnnAsFsRIZ");
destination.addFile(file);
var pull = DriveApp.getRootFolder();
pull.removeFile(file);
}
}
Error: TypeError: DriveApp.getRootFolder(...).getFiles(...).getFilesByName is not a function
Please tell me to set up the trigger every time a new file is created. Because I only want it to be uploaded only when a new file is created.