-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateImageReference.sh
More file actions
executable file
·49 lines (36 loc) · 1.76 KB
/
generateImageReference.sh
File metadata and controls
executable file
·49 lines (36 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
# Generates "IMAGES.md" containing a reference to all images (PNG) in this directory and its subdirectories.
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
set -o errexit -o pipefail
# Markdown file name
markdown_file="IMAGES.md"
echo "generateImageReference: Generating ${markdown_file}..."
{
echo "# Image Reference"
echo ""
echo "This document serves as a reference for all images (PNG) in the current directory and its subdirectories."
echo "It provides a table listing each file and the analysis it belongs to."
echo "This file was generated with the script [generateImageReference.sh](./../documentation/analysis-reports-reference/generateImageReference.sh)."
echo ""
echo "Image | Analysis |"
echo "-------|----------|"
} > ${markdown_file}
# Loop through all Markdown files in the current directory
find . -type f -name "*.png" | sort | while read -r image_file; do
# Trim leading and trailing whitespace
description=$(echo "${description}" | awk '{$1=$1;print}')
# Extract the script file name without the path
filename=$(basename "$image_file")
if [ "$filename" = "${markdown_file}" ]; then
continue
fi
# Extract the script file path without the name
pathname=$(dirname "$image_file")
# Extract the second part of the path after ./ that contains the analysis directory name
analysisname=$(echo "${pathname}" | cut -d/ -f 3)
# Create a link to the script file in the table
link="[${filename}](${image_file})"
# Add the script file and its description to the Markdown table
echo "| ${link} | ${analysisname%%.} |" >> ${markdown_file}
done
echo "generateImageReference: Successfully generated ${markdown_file}."