我正在使用谷歌应用程序脚本,我想检查/ root / Received Files / folderName是否存在。如果不存在那么我想创建它。 但是
时总是显示错误Subfolders.hasNext()
我该如何修复我的代码?
function getFolders(folderName)
{
var Subfolder;var Subfolders
var folders = DriveApp.getFolders();
while (folders.hasNext()) {
var folder = folders.next();
if('Received Files' == folder.getName()) {
Subfolders=folder;
while(Subfolders.hasNext()) ==> ERR
{
Subfolder=Subfolders.next();
if(folderName == Subfolder.getName())
{
return Subfolder
}
}
}
}
Subfolder=Subfolders.createFolder(folderName);
return Subfolder;
}
答案 0 :(得分:0)
你应该这样做:
Subfolders = folder.getFolders();
不
Subfolders = folder;