-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetect_images
executable file
·39 lines (36 loc) · 1.1 KB
/
detect_images
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
#!/bin/bash
# Tutorials:
for i in {1..11}; do
weeknum=${i}
if [[ ${#i} < 2 ]]
then
i="0${i}"
i="${i: -2}"
fi
images=$(grep -oE '!\[\]\(\.\./images/[^)]+\)' week${weeknum}/tutorial/tutorial-${i}.qmd | sed -E 's/!\[\]\(\.\.\/images\/([^)]+)\)/\1/')
mkdir -p week${weeknum}/images
for image in $images; do
echo "Processing image: $image"
# Use the cp command to copy the file to the new location
cp "images/"$image week${weeknum}/images/
done
done
echo "Processing lecture images"
# Lectures:
for i in {1..11}; do
weeknum=${i}
if [[ ${#i} < 2 ]]
then
i="0${i}"
i="${i: -2}"
fi
echo "Lecture ${i}"
# Finds everything in ![](images/) after the slash, and only keeps the bits after the slash
images=$(grep -oE '!\[\]\(images/[^)]+\)' week${weeknum}/index.qmd | sed -E 's/!\[\]\(images\/([^)]+)\)/\1/')
mkdir -p week${weeknum}/images
for image in $images; do
echo "Processing image: $image"
# Use the cp command to copy the file to the new location
cp "images/"$image week${weeknum}/images/
done
done