grefel
3/19/2016 - 12:55 PM

Remove Folder recursively

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();	
}