You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
714 B
Bash

#!/bin/bash
set -e
#
# this script compresses everything in $source and saves it in $destination
#
source="$HOME/kskcloud/Musik/"
export destination="$HOME/Musik.tiny/"
cd "$source"
# create directory structure
find . -type d -exec mkdir -p "$destination/{}" \;
# copy existing files
find . -type f -and \( -name '*.mp3' -or -name '*.ogg' -or -name '*.opus' \) -exec cp -a --reflink=always "{}" "$destination/{}" \;
# set +e because ffmpeg errors on .jpg, .txt, etc.
# compress with mp3
set +e
find . -type f -not -name '*.mp3' -not -name '*.ogg' -not -name '*.opus' | parallel --jobs 9 --eta --progress 'nice -n19 ffmpeg -v 0 -n -i ""{}"" -c:a mp3 -b:a 320 -map_metadata 0 ""$destination/{.}.mp3""'
#set -e