summaryrefslogtreecommitdiffstats
path: root/roles/prerec/templates/copy-original.sh
blob: 854bdb8713dffa41cb06073420c57bf3fcb4901d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
# {{ ansible_managed }}
# Usage: rename-original.sh $slug $file [$extra]
SLUG=$1
FILE=$2
EXTRA=""
if [ -z ${3-unset} ]; then
		EXTRA=""
elif [ -n "$3" ]; then
		EXTRA="$3"
elif echo "$FILE" | grep -e '\(webm\|mp4\|mov\)'; then
		EXTRA="--original"
fi
filename=$(basename -- "$FILE")
extension="${filename##*.}"
filename="${filename%.*}"
FILE_PREFIX=$(get-file-prefix $SLUG)
if echo "$FILE" | grep -q \\. ; then
		cp "$FILE" $FILE_PREFIX$EXTRA.$extension
		echo $FILE_PREFIX$EXTRA.$extension
else
		cp "$FILE" $FILE_PREFIX$EXTRA
		echo $FILE_PREFIX$EXTRA
fi