LinuxQuestions.org
Visit Jeremy's Blog.
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 04-20-2014, 02:48 PM   #1
popper09
LQ Newbie
 
Registered: Apr 2014
Posts: 3

Rep: Reputation: Disabled
Script for editing MP3s tag


Hi guys
I'm searching for a script in linux bash for editing MP3s tag.
More precisely I want to capitalize any word in the tags. For exemple, if there's an Artist tag "john petrucci" I want it to be "John Petrucci".
Could you help me?
Thanks
 
Old 04-20-2014, 02:55 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by popper09 View Post
Hi guys
I'm searching for a script in linux bash for editing MP3s tag.
More precisely I want to capitalize any word in the tags. For exemple, if there's an Artist tag "john petrucci" I want it to be "John Petrucci".
Could you help me?
Thanks
There are several perl modules for manipulating MP3 tags...you don't say what language you're wanting to write this in, but perl would be easy. Why don't you post what you've written/tried so far, and tell us where you're stuck, and we'll be happy to help.
 
Old 04-20-2014, 03:13 PM   #3
popper09
LQ Newbie
 
Registered: Apr 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
I'd want it in linux bash.
I've tried to write something in python (the only language I know) but I've got some problems. Also, I realized I need it on linux bash because there is not supposed to be a python interpreter on the machine I'll have to run the script.
 
Old 04-20-2014, 03:41 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by popper09 View Post
I'd want it in linux bash.
I've tried to write something in python (the only language I know) but I've got some problems. Also, I realized I need it on linux bash because there is not supposed to be a python interpreter on the machine I'll have to run the script.
What machine is that, running what version/distro of Linux? And there are lots of sample scripts you can find through Google....post what you've written/tried so far, and we can help. But we're not going to write your scripts for you.
 
Old 04-20-2014, 06:47 PM   #5
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
I would recommend to use a command line tag editor and call it from bash. I have little experience recently with tag editing, but it seems id3v2 is an option. Some grep, sed and awk and maybe tr should complete the script.

jlinkels
 
Old 04-21-2014, 12:47 AM   #6
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Rep: Reputation: 29
See if this gets you started in the right direction..
Code:
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
 
Old 04-21-2014, 02:09 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
In bash you can capitalize letters using the ^ and ^^ parameter expansion. Example:
Code:
$ name=john
$ echo ${name^}
John
To capitalize every first letter in a complete name, you have to assign it to an array, example:
Code:
$ name=( $(echo john belushi) )
$ echo ${name[@]^}
John Belushi
To be sure the names are capitalized as you desire, upon reading them from the original tag you may want to change all the letters to lowercase at first. In this case do
Code:
$ echo ${name[@],,}
john belushi
Some reference:
http://www.gnu.org/software/bash/man...eter-Expansion
http://www.gnu.org/software/bash/man...ef.html#Arrays
 
Old 04-22-2014, 01:29 PM   #8
popper09
LQ Newbie
 
Registered: Apr 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
***

Last edited by popper09; 04-26-2014 at 11:13 AM.
 
  


Reply



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
NCMPCPP tag editing resulting in incorrect characters goodvikings Linux - General 1 11-18-2013 12:18 AM
Need assistance with shell script - replace a string with a start tag and end tag SupermanInNY Programming 18 01-02-2010 05:44 PM
Mp3 tag editing? alaios Linux - Software 5 01-31-2009 05:10 AM
Editing the "tag" function. jens LQ Suggestions & Feedback 5 04-20-2006 08:17 AM
ID3 Tag Editing with a Shell Script chrisk5527 Linux - General 5 03-20-2003 10:38 PM

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

All times are GMT -5. The time now is 06:38 AM.

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