Code: Select all
2023_FamilyDrama.pdf
2024_FamilyDrama.pdf
2022-beachpics.pdf
2020 Hello_world bring fame.pdf
2019-this-is-my_doc.pdf
Code: Select all
FamilyDrama_2023.pdf
FamilyDrama_2024.pdf
beachpics_2022.pdf
Hello_world bring fame_2020.pdf
this-is-my_doc_2019.pdf
Code: Select all
import os
for root, dir, fname in os.walk(PATH):
for f in fname:
os.chdir(root)
if f.startswith('2024_'):
os.rename(f, f.replace('2024_', ''))