-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmove_slide.bash
executable file
·35 lines (27 loc) · 1.02 KB
/
move_slide.bash
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/bash
OLD_SLIDE_NUM="$1"
NEW_SLIDE_NUM="$2"
if [ -z "$OLD_SLIDE_NUM" ] || [ -z "$OLD_SLIDE_NUM" ]; then
echo "Usage: ./move_slide.bash OLD_SLIDE_NUM NEW_SLIDE_NUM" >&2
exit 1
fi
if [ "$OLD_SLIDE_NUM" -lt "$NEW_SLIDE_NUM" ]; then
mv "slides/$OLD_SLIDE_NUM.html" "moving_slide.html"
for slide in $(seq "$OLD_SLIDE_NUM" "$(expr "$NEW_SLIDE_NUM" - 1)"); do
next_slide="slides/$(expr "$slide" + 1).html"
if [ -f "$next_slide" ]; then
mv "$next_slide" "slides/${slide}.html"
else
rm -f "slides/${slide}.html"
fi
done
mv "moving_slide.html" "slides/$NEW_SLIDE_NUM.html"
elif [ "$OLD_SLIDE_NUM" -gt "$NEW_SLIDE_NUM" ]; then
mv "slides/$OLD_SLIDE_NUM.html" "moving_slide.html"
for slide in $(seq "$(expr "$OLD_SLIDE_NUM" - 1)" -1 "$NEW_SLIDE_NUM"); do
if [ -f "slides/${slide}.html" ]; then
mv "slides/${slide}.html" "slides/$(expr $slide + 1).html"
fi
done
mv "moving_slide.html" "slides/$NEW_SLIDE_NUM.html"
fi