script.py 519 B

1234567891011121314
  1. import re, os
  2. wiki_dir = "C:\\Coding\\python\\dropbox-pictures-regex\\wiki\\"
  3. # koment
  4. regex = r"(?:(?:https?)+\:\/\/+[a-zA-Z0-9\/\._-]{1,})+(?:(?:jpe?g|png))"
  5. for path, dirs, files in os.walk(wiki_dir):
  6. for file in files:
  7. if file.endswith('.md'):
  8. file_path = os.path.join(path, file)
  9. with open(file_path, 'r', encoding='utf8') as f:
  10. text = f.read()
  11. matches = re.findall(regex, text)
  12. print(f"Soubor: {file_path}\nobrazek: {matches}")