I have many mp3 songs in a directory and I want to sort them by artist such that each artist name is a directory containing that artist's music.
|
closed as not constructive by Dave M, Indrek, MaQleod, Mokubai, 8088 Oct 5 '12 at 20:50
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.
|
This assumes your mp3 tags are in id3v2 format. id3v1 formats things a little differently. I recommend something like
for file in *.mp3; do
IFS=$':'
artist="$(id3v2 -l "${file}" | grep "TPE1" | awk '{ print $2 }')"
# Your artist name is now stored in $artist.
# This example just creates an artist directory and moves the file into it.
# Terrible way to organize music, but this is a demonstration!
[[ ! -d "${artist}" ]] && mkdir -p "${artist}"
mv -f "${file}" "${artist}"
done
A real solution is to use something like MusicBrainz Picard. |
|||||||
|
|
I am not sure what OS you are on, but since your question was tagged as Unix-programming I will assume you are on an *ix. So, if you can install id3tool you could run the following BASH command line:
EXPLANATION: This little script will loop through each of your mp3 files, extract the artist's name using You can also do this in a GUI way by using music players such as amarok that offer this feature (or at least it used to). There are also various id3 editors, just search through your favorite software source, at least some of which should also be able to do this. |
|||||||
|
|
I would do this in Python, with the tool pointed out in this answer on Stack Overflow, eyeD3. |
|||||
|
|
