# #!/bin/sh if [ -z "$1" ] || [ -z "$2" ] then echo "Enter an input directory followed by an output directory!" exit else echo "Copying Directories..." fi find $1 -mindepth 1 -type d -print0| while read -d '' -r dir; do #echo $dir; d1=${dir#$1} #echo "$2$d1" mkdir -v "$2$d1" done #Link to all pictures, lyric files, etcetera. echo "Creating Links for non-audio files..." find $1 -iname '*.png' -o -iname '*.jpg' -o -iname '*html' -o -iname '*.lrc' -o -iname '*.txt' -o -iname '*.cue' -o -iname '*.exe' -o -iname '*.mpg' -o -iname '*.bmp' -o -iname '*.ico' | while read file; do #echo "$2${file#$1}" ln -P "$file" "$2${file#$1}" done echo "Copying pre-existing mp3s and unlinkable files..." find $1 -iname '*.mp3' -o -iname '*.log' -o -iname '*.m3u' -o -iname '*.m3u8' -o -iname '*.accurip' -o -iname '*pdf' -o -iname '*.rtf'| while read file; do cp "$file" "$2${file#$1}" done find $1 -iname 'desktop.ini' -o -iname 'Thumbs.db' -o -iname '*nfo'| while read file; do rm "$file" done echo "Converting audio... Please be Patient!" #find $1 -mindepth 2 -name '*.flac' -o -name '*.m4a' -o -name '*.wav' -o -name '*.mp4'| while read track; #find $1 -mindepth 2 -type d -print0 -name '*.flac'| while read -d '' -r dir #if [ $(( $(find "$dir"/*.flac | wc -l) + $(find "$dir"/*.m4a | wc -l) + $(find "$dir"/*.wav | wc -l) + $(find "$dir"/*.mp3 | wc -l) )) -le $(( $(find "$2${dir#$1}"/*.mp3 | wc -l) )) ] find "$1" -type f -name '*.flac' -printf '%h\n' | sort -u | while read dir do if [ $(( $(find "$dir"/*.flac | wc -l) )) -gt $(( $(find "$2${dir#$1}"/*.mp3 | wc -l) )) ] then track2track -t mp3 -q extreme -j 20 -d "$2${dir#$1}" "$dir"/*.flac #ffmpeg -i "$track" -vn -n -loglevel panic -threads 20 -map 0:a "${path%.*}".mp3 else echo "$2${dir#$1} Contains an equal number of mp3s..." fi done find "$1" -type f -name '*.m4a' -printf '%h\n' | sort -u | while read dir do if [ $(( $(find "$dir"/*.m4a | wc -l) )) -gt $(( $(find "$2${dir#$1}"/*.mp3 | wc -l) )) ] then track2track -t mp3 -q extreme -j 20 -d "$2${dir#$1}" "$dir"/*.m4a else echo "$2${dir#$1} Contains an equal number of mp3s..." fi done find "$1" -type f -name '*.mp4' -printf '%h\n' | sort -u | while read dir do if [ $(( $(find "$dir"/*.mp4 | wc -l) )) -gt $(( $(find "$2${dir#$1}"/*.mp3 | wc -l) )) ] then track2track -t mp3 -q extreme -j 20 -d "$2${dir#$1}" "$dir"/*.mp4 else echo "$2${dir#$1} Contains an equal number of mp3s..." fi done