79117829

Date: 2024-10-23 12:14:38
Score: 1
Natty:
Report link

@JZL003 solution is great, but parentFolder is not actually used, so code could be simplified further, such as:

function recurseFolder(myFolder) {
  var childfolders = myFolder.getFolders();   // get the list of sub folders in the root of that folder
  while (childfolders.hasNext()) {            // count the sub folders
    recurseFolder(childfolders.next());
  }
  var hasFile = myFolder.getFiles().hasNext();      // get the list of files in the root of that folder
  var hasFolder = myFolder.getFolders().hasNext();  // get the list of files in the root of that folder
  if (!hasFile && !hasFolder) {            
    myFolder.setTrashed(true);
  }             
}
Reasons:
  • Whitelisted phrase (-1): solution is
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @JZL003
  • Looks like a comment (1):
  • Low reputation (1):
Posted by: Tony Broadbent