- Add all the existing files.

This commit is contained in:
2026-04-10 18:46:38 +02:00
parent deba3dd53f
commit 5b141b45cf
14 changed files with 2219 additions and 0 deletions

138
bin/album_name_fix Executable file
View File

@@ -0,0 +1,138 @@
#!/bin/bash
. /usr/global/lib/music.bash
# System Constants
#-----------------------------------------------------------------------------------------------------------------------------------
ANF_VERSION="$Name: album_name_fix-1_0_0-1 $"
# Print Version
#-----------------------------------------------------------------------------------------------------------------------------------
function version_print()
{
echo ${ANF_VERSION} | sed -e 's/.*: //' -e 's/-/ /' -e 's/_/\./g' -e 's/\$$//'
}
# Prin Help
#-----------------------------------------------------------------------------------------------------------------------------------
function help_print()
{
echo "album_name_fix [-h | --help] | [-V | --version] | [-T | --test] [-v | --verbose] [-a <album_dir>] [-p|--music_pattern <music_pattern>] [-s|--sed_substitute_pattern <sed_substitue_pattern>]"
}
# Arg Parse
#-----------------------------------------------------------------------------------------------------------------------------------
function args_parse()
{
mode="default"
verbose="false"
album_dir="."
music_pattern="."
tmp_args=$(getopt -o a:p:s:ThVv --long album_dir:,music_pattern:,sed_substitute_pattern:,test,help,version,verbose -n 'album_name_fix' -- "$@")
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "${tmp_args}"
while true ; do
case "$1" in
# Path options
-a|--album_dir) shift; album_dir="$1"; shift;;
# Options
-p|--music_pattern) shift; music_pattern="$1"; shift;;
-s|--sed_substitute_pattern) shift; ssp="$1"; shift;;
# Mode switches
-T|--test) mode="test"; shift;;
-h|--help) mode="exit"; help_print; shift;;
-V|--version) mode="exit"; version_print; shift;;
# Global options
-v|--verbose) verbose="true"; shift;;
#
--) shift; break;;
*) echo "args_parse internal error [$1] !"; exit 1;;
esac
done
}
# Main
#-----------------------------------------------------------------------------------------------------------------------------------
shopt -s extglob
args_parse "$@"
if [[ ${mode} == "exit" ]]
then
exit 0
else
if [[ ${mode} == "test" ]]
then
dry_run=true
else
dry_run=false
fi
fi
echo "mode: [${mode}] verbose: [${verbose}] album_dir: [${album_dir}] music_pattern: [${music_pattern}] sed_substitue_pattern: [${ssp}]" 1>&2
cd "${album_dir}"
IFS="\n"
find . -maxdepth 1 -name '*.flac' -o -name '*.FLAC' -o -name '*.ogg' -o -name '*.OGG' -o -name '*.mp3' -o -name '*.MP3' -o -name '*.m4a' -o -name '*.M4A' -o -name '*.ape' -o -name '*.APE' -o -name '*.wav' -o -name '*.WAV' -o -name '*.mp4' -o -name '*.MP4' -o -name '*.mkv' -o -name '*.MKV' | sed -e 's/^.\///' | grep -e "${music_pattern}" | sort |
while read track_file
do
IFS=" "
new_track_file="$(fix_file_name "${track_file}" "${ssp}")"
if [[ "${new_track_file}" != "${track_file}" ]]
then
echo "Moving '${track_file}' into '${new_track_file}'..."
if [[ "${dry_run}" != "true" ]]
then
mv -- "${track_file}" "${new_track_file}"
else
if [[ "${verbose}" == "true" ]]
then
echo mv -- "${track_file}" "${new_track_file}"
fi
fi
else
echo "Skiping '${track_file}'..."
fi
IFS="\n"
done