How do I compose a PDF file from all the JPEG images in a folder for a Claude's project knowledge base?

echo "---" > temp.md
echo "header-includes:" >> temp.md
echo "  - \usepackage{graphicx}" >> temp.md
echo "  - \usepackage[a4paper, margin=0.2cm]{geometry}" >> temp.md
echo "  - \usepackage{pdflscape}" >> temp.md
echo "  - \usepackage{float}" >> temp.md
echo "  - \usepackage{lscape}" >> temp.md
echo "  - \pagenumbering{gobble}" >> temp.md
echo "---" >> temp.md
shopt -s nullglob
for file in *.jpg *.jpeg; do
    if [ -f "$file" ] && [ "$file" != "temp.md" ]; then
        filename=$(basename "$file")
        safe_filename=$(echo "$filename" | sed 's/[-_]/\\&/g')
        if identify -format "%[fx:w>h]" "$file" | grep 1 > /dev/null; then
            echo '\begin{landscape}' >> temp.md
            echo '\begin{minipage}{\linewidth}' >> temp.md
            echo "\Large\textbf{${safe_filename}}" >> temp.md
            echo '\vspace{0.1cm}\\' >> temp.md
            echo '\centering' >> temp.md
            echo '\includegraphics[height=0.98\textheight, width=\linewidth, keepaspectratio]{'"$file"'}' >> temp.md
            echo '\end{minipage}' >> temp.md
            echo '\end{landscape}' >> temp.md
        else
            echo '\begin{minipage}{\textwidth}' >> temp.md
            echo "\Large\textbf{${safe_filename}}" >> temp.md
            echo '\vspace{0.1cm}\\' >> temp.md
            echo '\includegraphics[height=0.98\textheight, width=\textwidth, keepaspectratio]{'"$file"'}' >> temp.md
            echo '\end{minipage}' >> temp.md
        fi
    fi
done
shopt -u nullglob
pandoc temp.md --pdf-engine=xelatex -o output.pdf