Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Has anyone got a bash script that will go through a media library and set the id3 title tag of each MP3 file to be equal to the file's name?

I'm open to other automated methods too. It can be a GUI application or anything that will do the job automatically.

An EasyTag method is noted here: How to rename bulk title tag in mp3 ID3 files — Unfortunately, I don't understand the steps.

share|improve this question
    
You may answer your own question. List the steps you found on ubuntuforums.org and cite your source. :) This will help future visitors to Superuser, in the case that the ubuntuforums.org link becomes unavailable. –  iglvzx Mar 9 '12 at 4:45
2  
Here are a few tips: 1) Don't clutter your question with "edit 1", "edit 2", etc. Resolve problems using comments. 2) If you find a solution, post it as an answer, as if you were trying to answer someone else's question. Don't put the answer into the question. That's not where people look for it :) Also, use blockquotes for anything you quote from somewhere else (see the formatting help). –  slhck Mar 9 '12 at 8:34

4 Answers 4

up vote 7 down vote accepted

EasyTAG is indeed a great tool for this problem. I found my answer here. In terms of how to use it, the best reference turns out to be EasyTAG’s own documentation.

Open EasyTag, navigate to a folder with music files in it, select all the files in the folder, or all the files you want to tag, click on the "Scan Files" button (you'll have to hover over them to figure out which one it is).

Then, make sure the scanner dropdown is set to "Fill Tag," then in the Fill Tag field, make the appropriate edits until the example below the field looks like what you're looking for. If you need further help as to what to put in the Fill Tag field, click on the "?" button for the legend (listing of what the different possible codes are to translate with) and hit the mask button to list some starting points.

When you're happy with the results, click the "Scan Files" button (in the Scan Files dialog box, not the one you originally clicked to get where you are...the icons look the same) and your changes will be applied. If you are not getting Artist or Album name, simply select all that you want to change, enter the data and click the little button next to that field and all files that are selected will the filled in or changed to that artist or album. This works in most fields.

When you're done, click the save button and you're done.

PS: The CDDB scanner often works pretty well, if you have full albums that you're trying to tag, or at least commercially available song files.

PPS: I am apparently half awake still. According to what you wrote in your original post, try this in the Fill Tag field:

%n. %a - %t

Here's the section that is relevant to this question:


1.2.2. Automatically with “Fill Tag” scanner:

Some conditions to use this mode:

  • files sorted by albums
  • filenames or parent directory contain tag information (artist, album, title, …)
  • empty or not correct tags

The “Fill Tag” scanner uses a pattern to associate words in the filename and directories with the tag entries. By this way, the tag fields can be completed automatically by pressing the “green” button in the scanner window or the toolbar. If the tag is partially completed, use the option “Overwrite fields when scanning tag” in the “Scanner” tab of the “Preferences” window, to replace all fields by the new values.

Each code correspond to a field, following theses rules :

Strings associated with code    Will fill the field
%a
  Artist
%b
  Album
%c
  Comment
%p
  Composer
%r
  Copyright
%e
  Encoded by
%g
  Genre
%i
  None! (used to ignore a string)
%l
  Number of tracks
%o
  Original artist
%n
  Track
%t
  Title
%u
  URL
%y
  Year

Note : to avoid mistakes, it is recommended to use a code only one time in the pattern. Of course, like when tagging manually, only the selected files are processed by the scanner. You can use the defined patterns in the list, or write yours own patterns to correspond to the format of yours file names and directories. To avoid mistakes when selecting the right pattern, or writing it, a preview shows immediately the results before to apply the pattern. If you need some help with the different codes, press the “Help” button (the lifebuoy) to display the legend of each code. Also, if you want to save yours own patterns, edit or sort then, by pressing the “Mask” button an little editor will be shown on the scanner window.

Below an example of use of patterns :

a) the following filename :

“/mnt/MP3/EVANESCENCE – Fallen (2003) – Rock/01. Going Under.mp3”

b) with the pattern :

“%a - %b (%y) - %g/%n. %t”

c) you will fill the tag with theses strings :

    Artist (%a) => EVANESCENCE
    Album (%b) => Fallen
    Year (%y) => 2003
    Genre (%g) => Rock
    Track (%n) => 01
    Title (%t) => Going Under
share|improve this answer
    
Thanks! This Helps a lot! –  S.Visser Dec 15 at 15:18

I have found a variety of command line tools to be useful:

id3v2

id3v2 is a command line id3v2 tag editor. You can add/modifiy/delete id3v2 tags and convert id3v1 tags to id3v2 tags. It's uses id3lib. I'm looking for a co-maintainer. Please email myers_carpenter if you are interested.

eyeD3

eyeD3 is a Python module and program for processing ID3 tags. Information about mp3 files (i.e bit rate, sample frequency, play time, etc.) is also provided. The formats supported are ID3 v1.0/v1.1 and v2.3/v2.4.

these are ideal when scripting something to scan directories.

share|improve this answer

This doesn't always get it exactly perfect, but I have used it to get the names of mp3 files using only common unix tools (including the busybox versions) Perhaps someone with more than just 6 Tom Petty mp3s can give it some further testing.

for x in *.mp3; do
  TITLE=$(strings "$x" |grep TAG |grep -v TAGL |sed "s/^.*TAG//g ; /^L$/d ; /^@$/d ; /^$/d ; /^Ac$/d")
  #mv "$x" "$TITLE.mp3"
  echo $x" "$TITLE.mp3" #just echo for now, until further tested
done

Edit: I misread the question, but knowing this above we can use sed to replace $TITLE with the name of the file "$x" by using sed to replace the string in place

sed -i "s/$TITLE/$x/" "$x"

I am almost 100% sure this does not meet all of the ID3 spec, but it may suffice for basic personal use as long as you make a backup first

share|improve this answer
    
Thanks. I found a way to accomplish my goal using EasyTAG, but your reply actually answers my original question best. strings is a good utility to know about. (I haven't used it before.) Could you post a complete solution based on your edit so I can be sure I understand the suggested change? –  MountainX Mar 13 '12 at 20:31

EasyTAG does all sorts of common batch tag/filename operations on audio (and some video) files.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.