-
Notifications
You must be signed in to change notification settings - Fork 0
/
syt.sh
executable file
·42 lines (38 loc) · 872 Bytes
/
syt.sh
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
#!/bin/sh
ARGS=$(getopt -a --options e:s:t: --long "exercise:,subject:,title:" -- "$@")
eval set -- "$ARGS"
EXERCISE=""
SUBJECT=""
TITLE=""
while true; do
case "$1" in
-e|--exercise)
EXERCISE="$2"
shift 2;;
-s|--subject)
SUBJECT="$2"
shift 2;;
-t|--title)
TITLE="$2"
shift 2;;
--)
break;;
*)
printf "Unknown option %s\n" "$1"
exit 1;;
esac
done
ZIPFILE=$(ls $HOME/Downloads/ | grep "UE$EXERCISE")
if test -z "$ZIPFILE"
then
echo "error: exercisefile not found"
exit 1
else
echo "located exercise: $ZIPFILE"
fi
echo "moving $ZIPFILE to $HOME/School"
mv "$HOME/Downloads/$ZIPFILE" "$HOME/School/"
echo "unzipping: $HOME/School/$ZIPFILE"
unzip "$HOME/School/$ZIPFILE" -d "$HOME/School/$SUBJECT/UE${EXERCISE}_${TITLE}"
echo "deleting: $HOME/School/$ZIPFILE"
rm -rf "$HOME/School/$ZIPFILE"