import os current_dir = os.getcwd() # Removing all .md files for root, dirs, files in os.walk(current_dir): for file in files: src_file = os.path.join(root, file) if os.path.isfile(src_file) and file.endswith(".md"): os.remove(src_file)