Created
January 12, 2013 12:27
-
-
Save mvanduijker/4517812 to your computer and use it in GitHub Desktop.
Simple script to export iTunes library to mp3. (use it for my car radio usb stick)
You need faad and lame
Tested on mac
brew install faad2 lame
This file contains 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 | |
itunes_folder="/Users/MacBookPro/Music/iTunes/iTunes Media/Music" | |
output_folder="/Users/MacBookPro/MP3s" | |
if [ ! -d "$output_folder" ]; then | |
mkdir -p "$output_folder" | |
fi | |
find "$itunes_folder" -type f | while read FILENAME; | |
do | |
file=$(basename "$FILENAME") | |
extension="${file##*.}" | |
file_no_ext="${file%.*}" | |
rel_path=${FILENAME/$itunes_folder/} | |
rel_path=${rel_path%$file} | |
if [ "$extension" = "m4a" ]; | |
then | |
target_folder="$output_folder$rel_path" | |
#create directory if not exists | |
if [ ! -d "$target_folder" ]; then | |
mkdir -p "$target_folder" | |
fi | |
faad -o - "$FILENAME" | lame -V2 - "$output_folder$rel_path$file_no_ext".mp3 | |
elif [ "$extension" = "mp3" ]; | |
then | |
#create directory if not exists | |
if [ ! -d "$target_folder" ]; then | |
mkdir -p "$target_folder" | |
fi | |
cp "$FILENAME" "$output_folder$rel_path$file" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment