From 63fff3f4c37fba81c70f7ac179710dee7777d329 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Fri, 7 Oct 2016 18:16:45 +0200 Subject: [PATCH] Add a script to rename meurice podcast --- README.md | 11 +++++++++++ rename_meurice_podcast | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 rename_meurice_podcast diff --git a/README.md b/README.md index 9eacfeb..73e64f7 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,17 @@ Then the script will: * I can display my current task and it's timer wherever i want (tmux, herbstluftwm, …) * Written to work with /bin/sh +## rename_meurice_podcast +I download some podcast from a RSS flux (http://www.franceinter.fr/emission-le-moment-meurice) but i don't like : +* the filename +* the title tag + +So it's a tiny script to correct this. I get the date and the "real" title from the "title" tag and : +* The filename become "$date_$realtitle.mp3" +* The title tag become "$date_$realtitle" + +"Le moment Meurice" : http://www.franceinter.fr/emission-le-moment-meurice + ## tag_photo.sh The main goal is to have a solution to know the "subject" of a picture without to open it and no really good name. It can happen if you delete your pictures and get it back with `photorec` or `foremost`. For this i use the Exif metadata. diff --git a/rename_meurice_podcast b/rename_meurice_podcast new file mode 100755 index 0000000..6f9731e --- /dev/null +++ b/rename_meurice_podcast @@ -0,0 +1,39 @@ +#!/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 +