diff options
author | Sacha Chua <sacha@sachachua.com> | 2025-01-23 08:58:18 -0500 |
---|---|---|
committer | Sacha Chua <sacha@sachachua.com> | 2025-01-23 08:58:18 -0500 |
commit | 745bba1474efe9161468d44bf959f4e830e3dce9 (patch) | |
tree | 5374c8f3694bdaa36607136a8935856e95426108 /roles/prerec/templates/copy-original.sh | |
parent | 964f44e68a0eba8dd49ab354c3739313f75914be (diff) | |
download | emacsconf-ansible-745bba1474efe9161468d44bf959f4e830e3dce9.tar.xz emacsconf-ansible-745bba1474efe9161468d44bf959f4e830e3dce9.zip |
convenience scripts
Diffstat (limited to 'roles/prerec/templates/copy-original.sh')
-rwxr-xr-x | roles/prerec/templates/copy-original.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/roles/prerec/templates/copy-original.sh b/roles/prerec/templates/copy-original.sh new file mode 100755 index 0000000..854bdb8 --- /dev/null +++ b/roles/prerec/templates/copy-original.sh @@ -0,0 +1,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 |