Start on the actual parsing of the music data.
This commit is contained in:
parent
92ac167e0f
commit
20161e48c5
@ -50,11 +50,11 @@ echo "** Tools are available."
|
|||||||
|
|
||||||
# Old Directory #
|
# Old Directory #
|
||||||
echo "* Checking whether OLD directory exists."
|
echo "* Checking whether OLD directory exists."
|
||||||
if [[ "`pwd`"== */OLD ]]; then
|
if [[ "`pwd`" == *"/OLD" ]]; then
|
||||||
echo "** We are in the folder, moving up a directory."
|
echo "** We are in the folder, moving up a directory."
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
if [[ ! -d OLD ]]; then
|
if [[ ! -d "OLD" ]]; then
|
||||||
echo "ERROR: Could not find a folder named 'OLD'."
|
echo "ERROR: Could not find a folder named 'OLD'."
|
||||||
echo " Please create it and add your library there."
|
echo " Please create it and add your library there."
|
||||||
fi
|
fi
|
||||||
@ -62,7 +62,7 @@ echo "** Folder exists appropriately."
|
|||||||
|
|
||||||
# Other Directories #
|
# Other Directories #
|
||||||
echo "* Ensuring working directories NEW and INTERIM exist."
|
echo "* Ensuring working directories NEW and INTERIM exist."
|
||||||
mkdir -pv $NEW $INT
|
mkdir -pv "$NEW" "$INT"
|
||||||
|
|
||||||
## Convert Media ##
|
## Convert Media ##
|
||||||
|
|
||||||
@ -70,14 +70,80 @@ echo "* Convert all files to mp3."
|
|||||||
find "$OLD" ! -name "*".mp3 | while read file; do
|
find "$OLD" ! -name "*".mp3 | while read file; do
|
||||||
ffmpeg -nostdin -hide_banner -loglevel quiet -i "$file" "$file".converted.mp3
|
ffmpeg -nostdin -hide_banner -loglevel quiet -i "$file" "$file".converted.mp3
|
||||||
done
|
done
|
||||||
echo "** Done creating mp3s."
|
echo "** Done converting mp3s."
|
||||||
|
|
||||||
## Transform Media ##
|
## Transform Media ##
|
||||||
|
|
||||||
echo "* Moving INTERIM files to NEW."
|
function migrate_music {
|
||||||
|
file="$1"
|
||||||
|
command="$2"
|
||||||
|
|
||||||
|
if [[ -z $file ]]; then
|
||||||
|
echo "ERROR: No filename retrieved, cannot migrate."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ -z "$command" ]]; then
|
||||||
|
command="cp"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "** $file **"
|
||||||
|
|
||||||
|
# Retrieve and clean the Title
|
||||||
|
title=""
|
||||||
|
title="`exiftool -Title "$file"`"
|
||||||
|
title="${title//Title /}"
|
||||||
|
title="${title// : /}"
|
||||||
|
title="${title//[^[:alnum:][:space:].]/}"
|
||||||
|
title="`echo $title`"
|
||||||
|
while [[ "$title" == *" "* ]]; do
|
||||||
|
title="${title// / }"
|
||||||
|
done
|
||||||
|
echo "*** Title=$title"
|
||||||
|
|
||||||
|
new_file="$title$EXT"
|
||||||
|
|
||||||
|
# Retrieve and clean the Track#
|
||||||
|
track=""
|
||||||
|
# Get raw value
|
||||||
|
track="`exiftool -Track "$file"`"
|
||||||
|
# Filter the header
|
||||||
|
track="${track//Track /}"
|
||||||
|
track="${track// : /}"
|
||||||
|
# Remove disk designations
|
||||||
|
track="${track%%/*}"
|
||||||
|
# Remove any whitespace before/after
|
||||||
|
track="`echo $track`"
|
||||||
|
# Add a leading 0 to single digits.
|
||||||
|
[[ ${#track} == 1 ]] && track="0$track"
|
||||||
|
echo "*** Track=$track"
|
||||||
|
|
||||||
|
new_file="$track. $new_file"
|
||||||
|
|
||||||
|
# Add the Album and Year.
|
||||||
|
|
||||||
|
|
||||||
|
new_file="$parent/$new_file"
|
||||||
|
|
||||||
|
# Add the Artist and Genre.
|
||||||
|
|
||||||
|
|
||||||
|
new_file="$grandparent/$new_file"
|
||||||
|
|
||||||
|
# Move the file.
|
||||||
|
new_file="$NEW/$new_file"
|
||||||
|
$command "$file" "$new_file"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "* Moving INTERIM files to NEW."
|
||||||
|
find "$INT" -name "*".mp3 | while read file; do
|
||||||
|
migrate_music "$file" mv
|
||||||
|
done
|
||||||
|
|
||||||
echo "** Done with INTERIM, deleting."
|
echo "** Done with INTERIM, deleting."
|
||||||
rm -rfv "$INT"
|
rm -rfv "$INT"
|
||||||
|
|
||||||
echo "* Copying OLD files to NEW."
|
echo "* Copying OLD files to NEW."
|
||||||
|
find "$OLD" -name "*".mp3 | while read file; do
|
||||||
|
migrate_music "$file" cp
|
||||||
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user