blob: ed085ed01cafae0d016acd893a2faa6cebae41e0 (
plain) (
tree)
|
|
#!/bin/bash
# {{ ansible_managed }}
# Usage: rename-original.sh $slug $file [$extra] [$talks-json]
SLUG=$1
FILE=$2
TALKS_JSON=${4:-~/current/talks.json}
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=$(jq -r '.talks[] | select(.slug=="'$SLUG'")["file-prefix"]' < $TALKS_JSON)
if echo "$FILE" | grep -q \\. ; then
mv "$FILE" $FILE_PREFIX$EXTRA.$extension
echo $FILE_PREFIX$EXTRA.$extension
else
mv "$FILE" $FILE_PREFIX$EXTRA
echo $FILE_PREFIX$EXTRA
fi
# Copy to original if needed
if [ -f $FILE_PREFIX--original.webm ] && [ ! -f $FILE_PREFIX--main.$extension ]; then
cp $FILE_PREFIX--original.$extension $FILE_PREFIX--main.webm
fi
|