Skip to content

Instantly share code, notes, and snippets.

@grefel
Created March 19, 2016 12:55
Show Gist options
  • Save grefel/61065d9e3c1d4557a3cd to your computer and use it in GitHub Desktop.
Save grefel/61065d9e3c1d4557a3cd to your computer and use it in GitHub Desktop.
Remove Folder recursively
function removeFolder(folder) {
var result = folder.getFiles();
for (var i = result.length -1; i >= 0; i--) {
var fileOrFolder = result[i];
if (fileOrFolder.exists) {
if (fileOrFolder.constructor.name == "Folder") removeFolder(fileOrFolder);
else fileOrFolder.remove();
}
}
folder.remove();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment