Created
January 26, 2016 11:36
-
-
Save smartest/07809b7f7a7cc1ed16d8 to your computer and use it in GitHub Desktop.
bin/cue file to iTunes alac auto import
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ ! -f "$1.cue" ]; then | |
echo "Argument '$1' is not a file."; | |
exit 1; | |
fi | |
dirtoremove="${1%/*}" | |
if [[ $(find flacs -type f | wc -l) -gt 0 ]]; then | |
echo "'flacs/' is not empty."; | |
exit 1; | |
fi | |
if [[ $(find alacs -type f | wc -l) -gt 0 ]]; then | |
echo "'alacs/' is not empty."; | |
exit 1; | |
fi | |
cuebreakpoints "$1.cue" | shnsplit -o flac -d flacs "$1.flac" | |
cuetag "$1.cue" flacs/split-track*.flac | |
find flacs -type f -name "*.flac" -exec bash -c 'basename=${0##*/};avconv -i "$0" -c:a alac "alacs/${basename%.*}.m4a"' '{}' \; | |
if [[ $(find alacs -type f | wc -l) -lt 1 ]]; then | |
echo "'alacs/' is empty. Nothing converted"; | |
exit 1; | |
fi | |
if [[ $(find alacs -type f | wc -l) -ne $(find flacs -type f |wc -l) ]]; then | |
echo "There may be an error during conversion. The number of files converted does not match."; | |
exit 1; | |
fi | |
mv alacs/* ../Libraries/iTunes에\ 자동으로\ 추가/ | |
echo $dirtoremove | |
rm -rf "$dirtoremove" | |
rm -rf flacs/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment