Renames statements from statements/Statement 17-dec-21 ac 01234567.PDF
to statements/2021-12-17.pdf
, as the latter is more easily sortable in a folder.
Created
April 29, 2022 14:51
-
-
Save opyate/4c0393651deaa409f4d466cb02076225 to your computer and use it in GitHub Desktop.
Rename Barclays statements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
from datetime import datetime | |
import os | |
statements_path = "statements" | |
p = Path(statements_path) | |
for f in p.glob('**/*.PDF'): | |
parts = f.name.split(" ") | |
datepart = parts[1] | |
isodate = datetime.strptime(datepart, "%d-%b-%y").strftime("%Y-%m-%d") | |
os.rename(f, f"{statements_path}/{isodate}.pdf") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment