Last active
November 6, 2022 00:26
-
-
Save ij96/e8c5bc9c04057d2cd4e2bcdc4fc5288a to your computer and use it in GitHub Desktop.
Rename MP3 files based on metadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rename MP3 files based on metadata (named artist and title) | |
# copy this script in the same directory as the MP3 files and run | |
# renamed MP3 are copied to renamed/ | |
mkdir renamed; | |
for f in *.mp3; do | |
TITLE=`ffmpeg -i "$f" 2>&1 | grep title | sed "s/ \+title \+: //"`; | |
ARTIST=`ffmpeg -i "$f" 2>&1 | grep artist | sed "s/ \+artist \+: //"`; | |
TRACK=`ffmpeg -i "$f" 2>&1 | grep track | sed "s/ \+track \+: //"`; | |
ZERO_TRACK=$(printf %02d ${TRACK}); # zero-padded track number | |
echo "Move $f to ${ARTIST} - ${TITLE}.mp3"; | |
cp "$f" "renamed/${ARTIST} - ${TITLE}.mp3"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment