Renommer les fichiers dans le dossier Python
import os
# Absolute path of a file
old_name = r"E:\demos\files\reports\details.txt"
new_name = r"E:\demos\files\reports\new_details.txt"
# Renaming the file
os.rename(old_name, new_name)
# for multiple files
import os
for dirname in os.listdir("."):
print((dirname[:-4]).zfill(6)+'.txt')
os.rename(dirname, (dirname[:-4]).zfill(6)+'.txt')
Merwanski