blob: 5784f4041f78c882520958b37213d43cda5ebf69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/usr/bin/env python3
import os
import re
year_re = r"(^\d{4})\d{2}\d{2}$"
month_re = r"^\d{4}(\d{2})\d{2}$"
day_re = r"^\d{4}\d{2}(\d{2}$)"
files = os.listdir(os.path.expanduser("~/me/journal"))
for f in files:
print("working: ", f)
if '.' in f:
continue
year = re.findall(year_re, f)[0]
month = re.findall(month_re, f)[0]
day = re.findall(day_re, f)[0]
os.rename(
"/home/ben/me/journal/{0}".format(f),
"/home/ben/me/journal/{0}.{1}.{2}".format(year, month, day)
)
|