From 8bc5ad978ccaad302d299356241f356e59716b15 Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Thu, 1 Dec 2022 12:12:16 -0600 Subject: Reverted to previous functionality due to bugs... made conversion prettier and more efficient! --- audioconversion.sh | 38 +++++++++++++++++++++++++++++--------- readme.txt | 1 - 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/audioconversion.sh b/audioconversion.sh index 496869b..cc0e917 100644 --- a/audioconversion.sh +++ b/audioconversion.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# #!/bin/sh if [ -z "$1" ] || [ -z "$2" ] then echo "Enter an input directory followed by an output directory!" @@ -31,14 +31,34 @@ do rm "$file" done echo "Converting audio... Please be Patient!" -find $1 -mindepth 2 -type d -print0| while read -d '' -r dir; -do - 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 "$2${dir#$1}"/*.mp3 | wc -l) > 0 ] +#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 - echo "$2${dir#$1} already contains converted files!" + 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 - track2track -t mp3 -q extreme -j 20 -d "$2${dir#$1}" "$dir"/*.flac "$dir"/*.wav "$dir"/*.mp4 "$dir"/*.m4a "$dir"/*.wv "$dir"/*.ape + echo "$2${dir#$1} Contains an equal number of mp3s..." fi - exiftool '-Filename<${TrackNumber;} - $Title.%e' "$2${dir#$1}"/*.mp3 #Included for files obtained from itunes... - exiftool '-Filename<${Track} - $Title.%e' "$2${dir#$1}"/*.mp3 -done + 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 \ No newline at end of file diff --git a/readme.txt b/readme.txt index e658752..d2987f7 100644 --- a/readme.txt +++ b/readme.txt @@ -2,6 +2,5 @@ This is a bash script for taking a directory and its contents and creating a dup ************ Dependencies: 1. track2track -2. exiftools ************ I've never written this kind of script before. Please contact me with advice or suggestions regarding syntax, functionality, etcetera. \ No newline at end of file -- cgit v1.2.3