0

I would like to move an entire folder including its subfolder to another folder using google script. I found this sample script on http://ctrlq.org/. However, the getfiles() method seems to limit to files under that folder. How can I solve this problem? Thanks in advance.

function moveFiles(source_folder, dest_folder) {
  
  var files = source_folder.getFiles();
 
  while (files.hasNext()) {
 
    var file = file.next();
    dest_folder.addFile(file);
    source_folder.removeFile(file);
 
  }
}
Daniel
  • 1
  • 1

2 Answers2

0

there is no need to move files inside a folder that is being moved. when you move a folder, the files and folders inside will move with it.

Zig Mandel
  • 19,571
  • 5
  • 26
  • 36
0

Get the files of root folder and again get all the subfolder then add up the list of files in root folder and its sub folders.

while (folders.hasNext()) {

var childfolder = folders.next();

var files = childfolder.getFiles();

while (files.hasNext())