Add files via upload
better shopt management and * as default setting for file-extensions
This commit is contained in:
parent
66b06937f5
commit
363553a5a4
1 changed files with 18 additions and 8 deletions
26
to_opus.sh
26
to_opus.sh
|
@ -1,18 +1,28 @@
|
||||||
#!/usr/bin/env bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# set shopt-options used by this shell-script
|
||||||
|
# Note, 0 (true) from shopt -q is "false" in a math context.
|
||||||
shopt -q globstar; globstar_set=$?
|
shopt -q globstar; globstar_set=$?
|
||||||
((globstar_set)) && shopt -s globstar
|
((globstar_set)) && shopt -s globstar
|
||||||
shopt -q extglob; extglob_set=$?
|
shopt -q extglob; extglob_set=$?
|
||||||
((extglob_set)) && shopt -s extglob
|
((extglob_set)) && shopt -s extglob
|
||||||
# Note, 0 (true) from shopt -q is "false" in a math context.
|
|
||||||
|
|
||||||
FORMATS=$@
|
|
||||||
|
|
||||||
for file in **/*.@(${FORMATS// /|}); do
|
|
||||||
ffmpeg -threads 4 -i "$file" -c:a libopus -b:a 128k "${file%.*}.opus" && rm "$file"
|
|
||||||
done
|
|
||||||
|
|
||||||
|
# return default shopt-options
|
||||||
|
function finish {
|
||||||
((globstar_set)) && shopt -u globstar
|
((globstar_set)) && shopt -u globstar
|
||||||
((extglob_set)) && shopt -u extglob
|
((extglob_set)) && shopt -u extglob
|
||||||
|
}
|
||||||
|
trap finish EXIT
|
||||||
|
|
||||||
|
# setting default extension to all
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
extension="*"
|
||||||
|
else
|
||||||
|
extension=$@
|
||||||
|
fi
|
||||||
|
|
||||||
|
for file in **/*.@(${extension// /|}); do
|
||||||
|
ffmpeg -threads 4 -i $file -c:a libopus -b:a 128k "${file%.*}.opus" && rm "$file"
|
||||||
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in a new issue