parameters: (path, exts)
return_statement: return del_count
docstring: Recursively delete all files with the given extension.
docstring_summary: Recursively delete all files with the given extension.
docstring_tokens: Recursively delete all files with the given extension .
function: def delete_files_with_extension(path, exts):
    """Recursively delete all files with the given extension."""
    del_count = 0
    for dir_path, subdirs, file_list in os.walk(path, topdown=False):
      for file_name in file_list:
        (_, file_ext) = os.path.splitext(file_name)
        if file_ext.lower() in exts:
          file_path = join_path(dir_path, file_name)
          os.remove(file_path)
          del_count += 1
      # Also remove any empty directories.
      for subdir_name in subdirs:
        subdir_path = join_path(dir_path, subdir_name)
        if not os.listdir(subdir_path):
          os.rmdir(subdir_path)
    return del_count
function_tokens: def delete_files_with_extension ( path , exts ) : del_count = 0 for dir_path , subdirs , file_list in os . walk ( path , topdown = False ) : for file_name in file_list : ( _ , file_ext ) = os . path . splitext ( file_name ) if file_ext . lower ( ) in exts : file_path = join_path ( dir_path , file_name ) os . remove ( file_path ) del_count += 1 # Also remove any empty directories. for subdir_name in subdirs : subdir_path = join_path ( dir_path , subdir_name ) if not os . listdir ( subdir_path ) : os . rmdir ( subdir_path ) return del_count