Files
3d-printer-models/generate-readme.sh
T
2025-06-08 08:57:36 -07:00

27 lines
841 B
Bash
Executable File

#!/bin/bash
HEADER_FILE="readme-header.md"
README_FILE="README.md"
# Create or truncate the README file
> $README_FILE
# Add the header to the README file
cat $HEADER_FILE >> $README_FILE
# Loop through each directory in the current working directory
for dir in */; do
# Extract and print the directory name without the trailing slash
echo -e "\n## ${dir%/}\n" >> $README_FILE
# Loop through all PNG files in the directory and embed them in the README file
for png in "$dir"*.png; do
[ -f "$png" ] || break # Break if no more PNG files are found
echo "![${png##*/}](${png})" >> $README_FILE
done
# Print a list of .scad files in the directory
echo -e "\nModel files:\n" >> $README_FILE
find "$dir" -type f -name '*.scad' | sed "s|$dir||g" | awk '{ print "* " $0 }' >> $README_FILE
done