rutaci: command line ruby music tagger

rutaci is a command line tool for manipulating the metadata of music files (among others id3 tags). You can display the metadata (also using a format string, useful for scripting), change the value of the different fields, extracting values from filenames and renaming files based on their metadata. It can operate on any fileformats suppoted by TagLib.

Installation

gem install rutaci

Depentencies:

Usage

$ rutaci [<options>] [get [<fields>]] <filenames...>
$ rutaci [<options>] set <fields and values> <filenames...>
$ rutaci [<options>] --format FORMAT rename <filenames...>
$ rutaci --help

Display metadata

The simples way to show the metadata of a music file is the following:

$ rutaci some_filename.mp3
Title: Some Title
Artist: Some Guy
Album: What Ever
Year: 2012

This will display all available fields. Note that rtaglib currently only implements the abstraction API, which means that we have only access to the most basic fields yet. To get only some specifig fields, you can use the get command followd by some field parameters (for each option there is a shortcut). It is also possible to give several filenames, their metadata will be separated by a blank line.

$ rutaci get --title --album some_file.mp3 some_other_file.mp3
... output ommited ...
$ rutaci get -ta *.mp3
... output ommited ...

Per default empty fields are not displayed, you can enable them with the --keep-empty-values option (shortcut -k). It can also be handy to ommit the leading field names if you want to use the values in shell scripts. For this use the --values-only (-o) option.

$ rutaci --values-only get --title some_filename.mp3
Some Title

The most powerfull is the --format option. Here you can specify a format string to format the output. This string is similar to printf’s (you can even use the printf flags) but the placeholder themself represent each time a specifc field.

$ rutaci --format "%n - %t" some_file.mp3
2 - Some Title
$ rutaci --format "| %02n | %-10.8t |" some_file.mp3
| 02 | Some Tit   |

The flags are the same as you may know them from printf. Currently the following format chars are implemented (they correspond to the shortcuts for the fieldnames):

t

Title (string)

i

Artist (string)

a

Album (string)

n

Tracknumber (integer)

y

Year (integer)

g

Genre (string)

c

Comment (string)

Renaming files

Using this format you can also rename files with the rename command:

$ rutaci --format "%02n - %t.mp3" some_filename.mp3
2 - Some Title.mp3
$ rutaci --format "%02n - %t.mp3" rename some_filename.mp3
current file: "some_filename.mp3"
  new name: "2 - Some Title.mp3"
$ rutaci --format "%.1i/%i/%a/%02n - %t.mp3" --destination /mnt/music rename some_filename.mp3
current file: "some_filename.mp3"
  new name: "/mnt/music/S/Some Artist/What Ever/2 - Some Title.mp3"

Missing directories are created on the fly. When using the --dry-run (-d) option, no files are actualy renamed. With the --interactive (-i) option, you can change the new filename before. This requires GNU readline. Note: Since I haven’t found a way (yet) to preset the value for the readline input, you have to use <TAB> key to get it via completion. Ctrl-C cancels the manipulation and uses the oritinal value.

Setting the metadata

Setting the metadata is also straight forward:

$ rutaci set --title "foo bar" --artist "Big R" some_filename.mp3
processing some_filename.mp3:
  setting title to "foo bar"
  setting artist to "Big R"
  writing the metadata
$ rutaci set -t "Big R" *.mp3
... output ommited ...
$ n=0; for f in *.mp3; do n=`expr $n + 1`; rutaci set -n $n "$f"; done
... output ommited ...

Ok, the last one isn’t that straight forward, but it’s a nice example of using rutaci together with the shell’s scripting abilities. It will set the tracknumber (-n) of every mp3 file in the current directory. It starts with 0 and increase the value by one before each assignement. As result, the files will have the tracknumbers 1, 2, 3, …

The options --dry-run and --interactive, as described in the rename section, also work with the set command. The fieldname parameters are the same as for the get command, only that they take a value this time.

It is also possible to extract the values from the filename, using a format string, just like for the get and rename command, only that it is used as a search pattern this time.

$ rutaci -d --format "%i - %a - %n - %t.mp3" set *.mp3
dry run for "Foo - Bar - 2 - What Ever.mp3"
  setting title to "What Ever"
  setting artist to "Foo"
  setting album to "Bar"
  setting track to 2
  writing metadata (it it wasn't a dry run ;-)
...

This will set every field that is present in the format string which are not empty. If you want to assign empty values (instead of ignoring them) you can use the --keep-empty-values option. To set only specific fields, you can set them after the set command. Note that there is no value this time, as it comes from the filename.

$ rutaci --interactive --format "%i - %a - %n - %t.mp3" set --title *.mp3
... output ommited ...

This is the same as above (without the dry run though) but it will only set the title. Before doing so the user has a chance to edit it. This requires GNU readline. See the interactive remark for the rename command

Legal stuff

Copyright © 2008 Jonas Bähr <[email protected]>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.