2019-10-24 02:20:38 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
PROJECTS_FOLDER=~/music-projects/Rendered-Projects
|
2020-03-02 07:40:13 +01:00
|
|
|
GARBADGE_FOLDER=/share
|
2019-10-24 02:20:38 +02:00
|
|
|
|
|
|
|
# file separator (needed to handle files with spaces)
|
|
|
|
IFS="
|
|
|
|
"
|
|
|
|
|
|
|
|
function info_log(){
|
|
|
|
echo -n ">>> [ "
|
|
|
|
echo -n $@
|
|
|
|
echo " ]"
|
|
|
|
}
|
|
|
|
|
|
|
|
function run_ffmpeg(){
|
|
|
|
local input=$1
|
|
|
|
local output=$2
|
|
|
|
|
|
|
|
info_log "ffmpeg : ${output}"
|
|
|
|
ffmpeg \
|
|
|
|
-i "${input}" \
|
|
|
|
-f mp3 \
|
|
|
|
-codec:a libmp3lame \
|
|
|
|
-qscale:a 5 \
|
|
|
|
-ar 44100 \
|
|
|
|
-loglevel error \
|
|
|
|
-af loudnorm \
|
|
|
|
"${output}"
|
|
|
|
}
|
|
|
|
|
|
|
|
function delete(){
|
|
|
|
local input=$1
|
|
|
|
|
|
|
|
if [[ -e "${input}" ]]
|
|
|
|
then
|
2020-03-02 07:40:13 +01:00
|
|
|
info_log "move : ${input} to ${GARBADGE_FOLDER}"
|
|
|
|
mv "${input}" "${GARBADGE_FOLDER}/$(basename ${input})"
|
|
|
|
#info_log "delete : ${input}"
|
|
|
|
#rm "${input}"
|
2019-10-24 02:20:38 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
for file in `ls ${PROJECTS_FOLDER} | grep wav$`
|
|
|
|
do
|
|
|
|
filename=`basename ${file} .wav`
|
|
|
|
mp3="${filename}.mp3"
|
|
|
|
|
|
|
|
info_log ${filename}
|
|
|
|
|
|
|
|
delete "${PROJECTS_FOLDER}/${mp3}"
|
|
|
|
run_ffmpeg "${PROJECTS_FOLDER}/${file}" "${PROJECTS_FOLDER}/${mp3}"
|
|
|
|
delete "${PROJECTS_FOLDER}/${file}"
|
|
|
|
|
|
|
|
done
|