-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean_image.sh
More file actions
36 lines (33 loc) · 806 Bytes
/
Copy pathclean_image.sh
File metadata and controls
36 lines (33 loc) · 806 Bytes
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
#!/bin/sh
for i in `find boards/ -name \*.yaml -mindepth 3`; do
board=$(basename $i .yaml)
d=$(dirname $i)
dd=$(basename $d)
if [ $dd != $board ]; then
continue
fi
if [ -f "$d/doc/img/$board.jpg" -o -f "$d/doc/img/$board.png" ]; then
echo "image available for $board: $d/doc/img/$board.png"
else
if [ -d "$d/doc" ]; then
pushd $d/doc
for ff in `find -name *.jpg -o -name *.png`; do
if [ -f "index.rst" ]; then
fig=$(grep ".. image::" index.rst)
if [ $? == "0" ]; then
echo
echo "Fixing $board"
echo
img=$(echo $fig | cut -d' ' -f3)
imgdir=$(dirname $img)
extension="${img##*.}"
mv $img $imgdir/$board.$extension
sed -i "s@$img@$imgdir/$board.$extension@" index.rst
fi
fi
break
done
popd
fi
fi
done