Created
January 16, 2022 08:12
-
-
Save oliverhu/a4eb76b7bbe7d72bc2f98edb8984e0c9 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
import urllib.parse | |
import re | |
import os | |
for root, dirs, files in os.walk("./"): | |
for file in files: | |
if file.endswith(".md"): | |
# f_base_name = urllib.parse.quote(os.path.basename(f_name)) | |
# print(f_base_name) | |
f_path = os.path.join(root, file) | |
p = re.compile(r"(.*)<a href.*>(.*.PDF)</a>(.*)", re.IGNORECASE) | |
f = open(f_path, 'r+') | |
file_contents = f.read() | |
file_contents = p.sub(f'![[\g<2>]]', file_contents) | |
f.seek(0) | |
f.truncate() | |
f.write(file_contents) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment