summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-05-11 13:08:18 +0200
committerErich Eckner <git@eckner.net>2017-05-11 13:08:18 +0200
commit8181f05e1f3c15a3c352c587fe10a96fcfef8327 (patch)
treeb31b61e61075c96b48a51f2a95d408d4bfabb916
parentfc6b9b3f0167becd9e0c04d87efe18b5f88edd3c (diff)
downloadsound-cutter-8181f05e1f3c15a3c352c587fe10a96fcfef8327.tar.xz
kann jetzt auch Dateien am Ende umbenennen
-rw-r--r--sound-cutter.in60
1 files changed, 57 insertions, 3 deletions
diff --git a/sound-cutter.in b/sound-cutter.in
index 2df6a4b..a164fc3 100644
--- a/sound-cutter.in
+++ b/sound-cutter.in
@@ -153,6 +153,32 @@ echo "${points}" | grep -q "\s" && \
[ -n "${tempDir}" ] && tempDir="--temp ${tempDir}"
+odn="$(dirname "$(readlink -f "${output}")")"
+obn="$(basename "${output}")"
+
+if [ "${obn%.*}" == "%s" ]
+then
+ names=(
+ $(
+ sed -n '/^[^#].*noNewFile/{N;d};/^#/{s|^.*#||;s|^ \+||;p}' "${points}" | \
+ tr ' -,.' '_'
+ )
+ )
+ obn="tmp_%n.${output##*.}"
+ for name in "${names[@]}"
+ do
+ if [ -e "${odn}/${name}.${obn#*.}" ]
+ then
+ if ${force}
+ then
+ ${dummy} || rm "${odn}/${name}.${obn#*.}"
+ else
+ >&2 echo "Die Ausgabedatei '${odn}/${name}.${obn#*.}' existiert bereits!" && exit 1
+ fi
+ fi
+ done
+fi
+
if [ -e "${output}" ]
then
if ${force}
@@ -162,8 +188,7 @@ then
>&2 echo "Die Ausgabedatei '${output}' existiert bereits!" && exit 1
fi
fi
-odn="$(dirname "$(readlink -f "${output}")")"
-obn="$(basename "${output}")"
+
if [ $(ls -1 "${odn}" | grep "$(echo "${obn}" | sed "s/%[0-9]\?n/.*/g")" | wc -l) -gt 0 ]
then
if ${force}
@@ -394,17 +419,46 @@ do
inputs[${i}]="|sox ${inputs[${i}]} -p${rejects[${i}]}"
done
+trackCount=$[1+$(
+ echo "${trimcmd}" | \
+ tr ' ' '\n' | \
+ grep -c '^newfile$'
+)]
+
+if [ ${trackCount} -ne ${#names[@]} ]
+then
+ >&2 echo "Die Anzahl der Namen (${#names[@]}) ist nicht gleich der Anzahl der Tracks (${trackCount})."
+ >&2 echo "Das sollte eigentlich nicht passieren koennen."
+ exit 1
+fi
+
echo sox ${tempDir} -M "${inputs[@]}" -p trim ${firstline}
echo sox ${tempDir} -t sox - -p ${repcmd}
echo sox ${tempDir} -t sox - -p ${trackmodcmd}
echo sox ${tempDir} -t sox - ${extraIn} -p ${splicecmd} ${remixcmd}
echo sox ${tempDir} -t sox - ${output} ${trimcmd}
+if [ -n "${names}" ]
+then
+ for ((i=0; i<${#names[@]}; i++))
+ do
+ echo mv "$(printf "%s/temp_%02d.%s" "${odn}" "$[${i}+1]" "${obn#*.}")" \
+ "$(printf "%s/%02d_%s.%s" "${odn}" "$[${i}+1]" "${names[${i}]}" "${obn#*.}")"
+ done
+fi
if ! ${dummy}
then
- sox ${tempDir} -M "${inputs[@]}" -p trim ${firstline}| \
+ sox ${tempDir} -M "${inputs[@]}" -p trim ${firstline} | \
sox ${tempDir} -t sox - -p ${repcmd} | \
sox ${tempDir} -t sox - -p ${trackmodcmd} | \
sox ${tempDir} -t sox - ${extraIn} -p ${splicecmd} ${remixcmd} | \
sox ${tempDir} -t sox - ${output} ${trimcmd}
+ if [ -n "${names}" ]
+ then
+ for ((i=0; i<${#names[@]}; i++))
+ do
+ mv "$(printf "%s/temp_%02d.%s" "${odn}" "$[${i}+1]" "${obn#*.}")" \
+ "$(printf "%s/%02d_%s.%s" "${odn}" "$[${i}+1]" "${names[${i}]}" "${obn#*.}")"
+ done
+ fi
fi