scripts/rename_meurice_podcast

40 lines
1.2 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# Rename Guillaume Meurice podcast files
# Also change the title tag (2016.09.30 Title)
# http://radiofrance-podcast.net/podcast09/rss_14257.xml
MEURICE_DIR="${1}"
TMP_LIST_FILE="/tmp/list_meurice_file"
# List audio files
find "${MEURICE_DIR}" -mindepth 1 -type f -iregex '.*\.mp3' > "${TMP_LIST_FILE}"
while IFS= read -r FILE
do
FILE_ABSOLUT_PATH="${MEURICE_DIR}/${FILE}"
# Get file information
FILE_EXT=$(echo "${FILE_ABSOLUT_PATH}" | awk -F'[.]' '{print $NF}')
# Get tag information
DATE=$(eyeD3 "${FILE_ABSOLUT_PATH}" | grep 'title' 2> /dev/null | sed 's/.*\(..\).\(..\).\(201.\).*/\3-\2-\1/')
TITLE=$(eyeD3 "${FILE_ABSOLUT_PATH}" | grep 'title' 2> /dev/null | sed 's/.*: \(.*\) \(..\).\(..\).\(201.\).*/\1/')
printf '%s\n' "date: ${DATE}"
printf '%s\n' "title: ${TITLE}"
# Correct title tag
command eyeD3 --title="${DATE} ${TITLE}" "${FILE_ABSOLUT_PATH}"
# Rename the file
#cp "${FILE}" "${MEURICE_DIR}"/"${DATE}"_"${TITLE}"."${FILE_EXT}"
#cp "${MEURICE_DIR}"/"${FILE}" "${MEURICE_DIR}"/"${DATE}"_"${TITLE}"."${FILE_EXT}"
mv "${FILE_ABSOLUT_PATH}" "${MEURICE_DIR}"/"${DATE}"_"${TITLE}"."${FILE_EXT}"
done < "${TMP_LIST_FILE}"
exit 0