- Add VSL support,
- Support now rx3-base 1.2.0.
This commit is contained in:
@@ -39,14 +39,15 @@
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
declare -g VERSION="1.1.0"
|
||||
declare -g NAME="album_retitle"
|
||||
declare -g VERSION="1.1.3"
|
||||
declare -g NAME="Album_Retitle"
|
||||
declare -g HELP="usage: [-h | --help] | [-V | --version] | [-T | --test] [-v | --verbose] <source_dir> <target_dir> <title_file>"
|
||||
|
||||
declare -g SOURCE_DIR=""
|
||||
declare -g TARGET_DIR=""
|
||||
declare -g TITLE_FILE=""
|
||||
|
||||
declare -g EXIT_CODE=0
|
||||
declare -g MODE="DEFAULT"
|
||||
declare -g VERBOSE="FALSE"
|
||||
declare -g DRY_RUN="FALSE"
|
||||
@@ -74,7 +75,6 @@ ar_version_print()
|
||||
|
||||
ar_help_print()
|
||||
{
|
||||
ar_version_print
|
||||
help_print
|
||||
}
|
||||
|
||||
@@ -102,8 +102,8 @@ ar_args_parse()
|
||||
|
||||
# Mode switches
|
||||
-T|--test) MODE="TEST"; shift;;
|
||||
-h|--help) MODE="EXIT"; ar_help_print; shift;;
|
||||
-V|--version) MODE="EXIT"; ar_version_print; shift;;
|
||||
-h|--help) MODE="HELP"; shift;;
|
||||
-V|--version) MODE="VERSION"; shift;;
|
||||
|
||||
# Global options
|
||||
-v|--verbose) VERBOSE="TRUE"; shift;;
|
||||
@@ -114,7 +114,7 @@ ar_args_parse()
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "${MODE}" != "EXIT" ]]
|
||||
if [[ "${MODE}" == "DEFAULT" ]]
|
||||
then
|
||||
if [[ "${#}" != "3" ]]
|
||||
then
|
||||
@@ -125,8 +125,8 @@ ar_args_parse()
|
||||
echo_error "Too many args!"
|
||||
fi
|
||||
|
||||
MODE="EXIT"
|
||||
ar_help_print
|
||||
MODE="HELP"
|
||||
EXIT_CODE=1
|
||||
else
|
||||
SOURCE_DIR="$1"
|
||||
TARGET_DIR="$2"
|
||||
@@ -142,53 +142,67 @@ ar_args_parse()
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
vsl_add
|
||||
|
||||
ar_args_parse "$@"
|
||||
|
||||
|
||||
case "${MODE}" in
|
||||
"EXIT")
|
||||
exit ${EXIT_CODE}
|
||||
;;
|
||||
|
||||
"HELP")
|
||||
ar_help_print
|
||||
exit ${EXIT_CODE}
|
||||
;;
|
||||
|
||||
if [[ "${MODE}" == "EXIT" ]]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
if [[ "${MODE}" == "TEST" ]]
|
||||
then
|
||||
"TEST")
|
||||
DRY_RUN="TRUE"
|
||||
fi
|
||||
fi
|
||||
|
||||
;;
|
||||
|
||||
"VERSION")
|
||||
ar_version_print
|
||||
exit ${EXIT_CODE}
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
echo_error "${NAME}: Mode: [${MODE}] Verbose: [${VERBOSE}] Source_Dir: [${SOURCE_DIR}] Target_Dir: [${TARGET_DIR}] Title_File: [${TITLE_FILE}]"
|
||||
|
||||
|
||||
if [[ ! -d "${TARGET_DIR}" ]]
|
||||
then
|
||||
echo_error "Target directory doesn't exist !"
|
||||
exit -1
|
||||
EXIT_CODE=1
|
||||
else
|
||||
if [[ ! -f "${TITLE_FILE}" ]]
|
||||
then
|
||||
echo_error "Title file doesn't exist !"
|
||||
EXIT_CODE=1
|
||||
else
|
||||
i=1
|
||||
|
||||
while read -r title
|
||||
do
|
||||
j=$(printf "%02d" "${i}")
|
||||
file=("${SOURCE_DIR}"/${j}-*.@(.flac|.mp3))
|
||||
suffix="${file##*.}"
|
||||
target_file="${TARGET_DIR}/$(mt_fix_file_name "${j}-${title}.${suffix}")"
|
||||
|
||||
echo_error "${NAME}: [${file}] -> [${target_file}]"
|
||||
|
||||
cmd_exec cp "${file}" "${target_file}"
|
||||
|
||||
mt_tag_delete "${target_file}" "TRACKNUMBER"
|
||||
mt_tag_delete "${target_file}" "TITLE"
|
||||
mt_tag_write "${target_file}" "TRACKNUMBER" "${j}"
|
||||
mt_tag_write "${target_file}" "TITLE" "${title}"
|
||||
|
||||
i=$(( i + 1 ))
|
||||
done < "${TITLE_FILE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -f "${TITLE_FILE}" ]]
|
||||
then
|
||||
echo_error "Title file doesn't exist !"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
i=1
|
||||
|
||||
while read -r title
|
||||
do
|
||||
j=$(printf "%02d" "${i}")
|
||||
file=("${SOURCE_DIR}"/${j}-*.@(.flac|.mp3))
|
||||
suffix="${file##*.}"
|
||||
target_file="${TARGET_DIR}/$(mt_fix_file_name "${j}-${title}.${suffix}")"
|
||||
|
||||
echo_error "${NAME}: [${file}] -> [${target_file}]"
|
||||
|
||||
cmd_exec cp "${file}" "${target_file}"
|
||||
|
||||
mt_tag_delete "${target_file}" "TRACKNUMBER"
|
||||
mt_tag_delete "${target_file}" "TITLE"
|
||||
mt_tag_write "${target_file}" "TRACKNUMBER" "${j}"
|
||||
mt_tag_write "${target_file}" "TITLE" "${title}"
|
||||
|
||||
i=$(( i + 1 ))
|
||||
done < "${TITLE_FILE}"
|
||||
exit ${EXIT_CODE}
|
||||
|
||||
Reference in New Issue
Block a user