问题
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);
}
}
回答1:
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.
回答2:
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())
来源:https://stackoverflow.com/questions/30240322/google-script-move-folders