import os names = [] for entry in os.scandir('projects'): if not entry.name.startswith('.') and entry.is_dir(): names.append(entry.name) for name in names: os.rename(f'projects/{name}/documentation.md', f'projects/{name}/{name}.md')