Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Figreturner

Updated: 21 dec 2025

Return figure for md Note that you should replace %5C with / and %20 with space

import os
from urllib.parse import quote

directory = '..'

def find_jpg_files(directory):
    markdown_links = []
    # Loop door de directory en alle subdirectories
    for root, dirs, files in os.walk(directory):
        for file in files:
            if file.endswith(".jpg"):
                # Creëer het volledige pad naar het bestand
                full_path = os.path.join(root, file)
                # Converteer het pad naar een relatief pad (verwijder de opgegeven root directory uit het pad)
                relative_path = os.path.relpath(full_path, directory)
                # Encode the path for use in URL, preserving slashes and spaces
                url_encoded_path = quote(relative_path, safe='/ ')
                # Formatteer het pad en de bestandsnaam als een Markdown link

                
                markdown_link = f"``` {directory}/{url_encoded_path} \n--- \nwidth: 50% \n```"
                markdown_links.append(markdown_link)
    return markdown_links

# Stel de root directory in waar je wilt beginnen met zoeken naar PDFs
pdf_links = find_jpg_files(directory)


# Print alle gevonden Markdown links
for figs in pdf_links:
    print(figs)