We can extend the core directory helper.  Creating a new file as MY_directory_helper.php and add the following code in helper file to remove directory and it’s sub folders &  files.