Created
July 23, 2018 23:41
-
-
Save WincerChan/6a37304b08ff223fe3a9de110a4772c0 to your computer and use it in GitHub Desktop.
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 os import listdir | |
def main(): | |
for file in listdir("./"): | |
if file.endswith('.md'): | |
single(file) | |
def single(file): | |
with open(file, 'r') as f: | |
lines = date_fmt(f.readlines()) | |
with open(file, 'w') as f: | |
f.writelines(lines) | |
def date_fmt(lines): | |
for line in lines: | |
print(line) | |
if line.startswith('date:'): | |
time = line[6:].replace('\n', '').replace( | |
'\'', '').replace('/', '-').split(' ') | |
lines[lines.index( | |
line)] = "date: {}T{}+08:00\n".format(time[0], time[1]) | |
return lines | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment