public static void deleteChilsDirsIfEmpty ( File dir ) { File childs [ ] = getChildDirs ( dir ) ; for ( File file : childs ) { deleteChilsDirsIfEmpty ( file ) ; if ( ! file . delete ( ) ) { log . info ( "No se ha podido borrar el directorio " + file . getAbsolutePath ( ) ) ; } } }
This delete the child dirs of the current dir only if the child dirs are empty or contains other dirs only