forked from varia/varia.website
adding a toolbox
This commit is contained in:
parent
3246d01f69
commit
6f7dc06d13
23
toolbox/change-category-to-tag.py
Normal file
23
toolbox/change-category-to-tag.py
Normal file
@ -0,0 +1,23 @@
|
||||
import os
|
||||
|
||||
folder = 'announcement/'
|
||||
filenames = os.listdir(folder)
|
||||
for filename in filenames:
|
||||
print('---'+filename+'---')
|
||||
out = []
|
||||
f = open(folder+filename, 'r')
|
||||
lines = f.readlines()
|
||||
for line in lines:
|
||||
tmpline = line.lower()
|
||||
if 'category:' in tmpline:
|
||||
category = tmpline.replace('category:', '').strip()
|
||||
continue
|
||||
elif 'tags' in tmpline:
|
||||
line = line + ', {}'.format(category)
|
||||
out.append(line)
|
||||
|
||||
outstring = '\n'.join(out)
|
||||
print(outstring)
|
||||
outfile = open(folder+filename, 'w')
|
||||
#outfile.write(outstring)
|
||||
outfile.close()
|
14
toolbox/change-image-url.py
Normal file
14
toolbox/change-image-url.py
Normal file
@ -0,0 +1,14 @@
|
||||
import os
|
||||
|
||||
folder = 'content/'
|
||||
filenames = os.listdir(folder)
|
||||
for filename in filenames:
|
||||
if '.md' in filename:
|
||||
print('---'+filename+'---')
|
||||
text = open(folder+filename, 'r').read()
|
||||
text = text.replace('/images/', 'images/')
|
||||
print(text)
|
||||
|
||||
outfile = open(folder+filename, 'w')
|
||||
outfile.write(text)
|
||||
outfile.close()
|
Loading…
Reference in New Issue
Block a user