Hi everyone,
I’m an absolute beginner in programming and I need some guiding.
This is what I want to do:
Copy a particular file located in a subfolder in Drive and paste it into multiple subfolders using Google Script.
This is what I’ve done so far:
function copyFilesintoMultipleFolders() {
var srcFolder = DriveApp.getFolderById("XXXXXXXXXXXXXXXXXXXXXXXX")
var dstFolder = DriveApp.getFolderById("YYYYYYYYYYYYYYYYYYYYYYYY")
var file = DriveApp.getFileById("ZZZZZZZZZZZZZZZZZZZZZZZZ")
while (dstFolder.hasNext()){
var f = file.makeCopy(dstFolder)
if (file.getMimeType() == MimeType.GOOGLE_APPS_SCRIPT){
Drive.Files.update({"parents": [{"id": dstFolder}]}, f.getId());
}
}
}
But I got stuck at the while loop because I get this error: “TypeError: Cannot find function hasNext”.
What did I do wrong? My dstFolder has multiple subfolders and I’ve tried to copy the file in all those multiple subfolders but I don’t know why hasNext doesn’t work.
Can anyone please guide me?
Much appreciated!