Bash script to set title of MP3 file equal to name of MP3 file
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Bash script to set title of MP3 file equal to name of MP3 file
I bought a tutorial to help me learn a foreign language and want to put the lessons on my ipod. However, none of the hundreds of mp3 files have any tag information. I was able to use eyeD3 to name the artist and album on all the files in batch mode, but none of the files has a title. So when I loaded them into my ipod, no titles are visible. Since the file names are of the form lesson001.mp3, lesson002.mp3, etc, the filenames are ok to use as titles. But how do I do some sort of batch command to place the filename into the 'title' field of the tag? I'm sure there is some simple way to do this using a bash script, but it's been decades since I wrote a bash script. Help!
It can more than likely be done via BASH but I am not familair enough with how the meta-data is setup for the file title etc.. I'll do some searching on that and see if I can help. I'm sure someone else here knows more about the way the mp3 files retain that data and may be able to help more directly but I'll see what I can find.
This is what I tried, but although it echoed the proper commands, it did not actually perform the commands and no changes were made in the id3 tags of the mp3 files.
for x in `ls`; do echo "eyeD3 --title='$x' file $x"; done
remove the echo, your not telling the system to execute the eyeD3 command, just to echo it. I was finding similar info and was about to post a similar for loop.
#!/bin/bash
##use 'mp3info' to insert data tags in 'mp3' files.
# check if there is no command line argument
if [ $# -eq 0 ]
then
echo "You forgot the information."
echo "This is only for 1 albun name and 1 artist."
echo "3 fields are required artist, album, genre, in that order."
echo "Either no spaces in each field or use quotation marks around each field."
exit
fi
artist=$1;
album=$2;
genre=$3;
for filename in *mp3; ##list all mp3 names in directory
do
if [ -f "$filename" ]
then
song_name=${filename%.mp3};
mp3info -t "$song_name" -a "$artist" -l "$album" -g "$genre" "$filename";
else
:
fi
done
exit
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.