LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 07-10-2012, 01:48 PM   #1
jwbales
LQ Newbie
 
Registered: Nov 2005
Location: Waverly, AL
Distribution: Ubuntu
Posts: 9

Rep: Reputation: 0
Unhappy 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!
 
Old 07-10-2012, 02:16 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
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.
 
Old 07-10-2012, 04:04 PM   #3
jwbales
LQ Newbie
 
Registered: Nov 2005
Location: Waverly, AL
Distribution: Ubuntu
Posts: 9

Original Poster
Rep: Reputation: 0
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
 
Old 07-10-2012, 04:14 PM   #4
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
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.
 
1 members found this post helpful.
Old 07-10-2012, 11:17 PM   #5
jwbales
LQ Newbie
 
Registered: Nov 2005
Location: Waverly, AL
Distribution: Ubuntu
Posts: 9

Original Poster
Rep: Reputation: 0
Yes, thank you, removing the echo helped, but the script still failed. Eventually I figured out how to use EasyTag to accomplish the task.
 
Old 07-10-2012, 11:42 PM   #6
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

also you should replace youtr `ls` with *. Also the "file" should not be there. Ie

Code:
for x in * ; do
  eyeD3 --title="$x" $x
done
Finally, you might like to strip the filename extension from the title.
Eg.
Code:
for x in * ; do
  eyeD3 --title="${x%.*}" $x
done
HTH,

Evo2.
 
Old 09-15-2013, 01:19 PM   #7
sazary
LQ Newbie
 
Registered: Sep 2013
Posts: 1

Rep: Reputation: Disabled
if your file names have spaces (like my files!) you should change 2nd line to:

Code:
  eyeD3 --title="${x%.*}" $x
 
Old 09-15-2013, 09:20 PM   #8
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Rep: Reputation: 29
Here is a script I use.

Code:
#!/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
 
  


Reply

Tags
bash scripting, id3, mp3, tags



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Script to automatically merge 2 wav files in 1 mp3 file Jackuss Linux - Newbie 5 12-02-2009 01:32 AM
if file *.txt then do x else if *.mp3 file then do xx (bash) Techno Guy Linux - Newbie 3 04-12-2009 08:52 PM
Need assistance with shell script to pull MP3 file Cpare Linux - Newbie 5 06-28-2008 08:53 PM
How to play a media file/ video file/mp3 file recorded in harddisk/cd-rom arindam Linux - Newbie 2 09-05-2003 10:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration