cdd

For any subject write to tbin@libero.it

Intro: what is cdd?
custom.data and add2cdd
Download
Well, I don't ask money for the programs I create. But if you want to sustain my work, feel free to donate any amount you can, using the PayPal button down below. In any case, whatever is your decision, go on surfing.

Intro: what is cdd?

cdd is a UNIX utility, written in bash, that operates on a text file cd database for extracting information and data and reporting all in a pretty format. The program has various options to control its behavior, and may be customizable to some extent.
The package contains the following files:
Let's begin. The database is formed by N text lines (being N the number of the cd records you want to put into the database), each containing five fields:
All fields are separated by a special character (defined in custom.data): by default it's the vertical bar |. Here's an example:
led zeppelin|bbc sessions|v.v.|1997|tracks from studio and live

The format is quite unreadable, but it's pure text, and may be altered by any editor.

The simplest usage is cdd <pattern> (attention: all files must reside in the same directory) as in the following example:
$ cdd led
The output will be

led zeppelin    bbc sessions    v.v.    1997    from studio and live

(the database is all in lower letters, but you can use patterns in any character, since cdd in case-insensitive). cdd has searched through the database and reported all the lines containing the pattern "led" (it could have been in the title or in the notes, for example). Another useful usage is:
$ cdd -a
this command (-a option, no patterns) simply prints out the whole database in raw format (a stands for all). Here's what happens here:

bruce, jack     songs for a tailor      1969    1997]
dandy wharols   the dandy wharols       1996    1996
led zeppelin    bbc sessions    v.v.    1997    from studio and live
pat metheny group       letter from home        1989    1989
......
......

The format is still raw, but the separator has been changed, so the lines are much more readable. Now that you've understood the principles, here's the output of the -h options (h for help):

$ cdd -h

Usage: cdd [OPTIONS] [pattern]
Options:
  -a            print all voices in the database
  -A            align output in fixed-size colunms (may trim fields)
  -c            report total number of records in the database and exit
  -C            add number of records found to search report
  -f <file>     extract info from <file> rather than from cd.db
  -F            frame output (may end in a long listing)
  -h --help     print this help and exit
  -n            print record number for each output line (unformatted outputs)
  -N            print output in plain format (may give uneasy listing)
  -o a|r|y|i|n  output only selected field (unifying multiple identical lines)
  -r            reverse sorting
  -s a|r|y|i|n  sort records only according to selected field
  -v --version  print version and exit
  -x a|r|y|i|n  limit search only to selected field
  -y            print a note about issue years rules and exit
Notes:
1. -s, -x, -o options must be followed by a selector char for field:
     a   artist name,
     r   record title,
     y   year of original record issue,
     i   CD manufacture year, if found (type cdd -y for info),
     n   notes about the recordings (if any);
2. -o selected output has precedence over -A aligned or -F framed modes;
3. if set together, the last among -A, -F and -N determines the output format.
4. if no pattern is given, cdd will silently quit.

Now you can understand how powerful it is. For example, here's an output with the -A option (A for aligned):

$ cdd -A -a

bruce, jack          songs for a tailor        1969 1997]                 
dandy wharols        the dandy wharols         1996 1996                  
led zeppelin         bbc sessions              v.v. 1997  from studio and live
pat metheny group    letter from home          1989 1989                   

or an output with the -F option (F for formatted) and -C (C for count found records)

$ cdd -F -C from
artist:    led zeppelin
album:     bbc sessions
issued in: v.v.          cd date:   1997
notes:     from studio and live
------------------------------------------------------------------------------

artist:    pat metheny group
album:     letter from home
issued in: 1989          cd date:   1989
notes:  
------------------------------------------------------------------------------
2 records found.

Explore other options on your own (for instance, -o control which field should be printed, and -x limit the search to the specified field).



As a final note, I explain the symbols I use appended to the issue or recording years to make clear their relationship (-y option):
$ cdd -y

THE SPECIAL MARKERS AND THE SYMBOLS OF THE DATABASE

Usually, cd date may be the same of the cd first issue (which means the record
is rather recent) or they differ if it's a reprint, maybe from an LP.
CD manufacture date is so followed by a special marker:

> means no reprint date is found, but track listing is complete; e.g.: 1972>
] means a reprint date is found, and track listing is complete;  e.g.: 2005]

Bootlegs, live and original collections should report the > or ] marker.

If the issue and manufacture years differ and no special marker is present,
the cd __does not__ feature the same track listing of the original record
(excluding any additional bonus track).
The output is influenced by the ']' and '>' markers; if cdd suspects that
the record hasn't got an original tracking list, or that you've typed a wrong
year, an asterisk (*) is printed after the issue year.

Other conventions:

v.v. means 'various years' (the record is typically a collection);
^^^^ means 'unknown data' (unavailable)

Of course, your database may be structured in a different way.

custom.data and add2cdd

custom.datais a shell script (not executable, in my intentions) that contains some customizable elements: the name of the database (its whole path, in effect), the separator used to limit the record fields, the main view format, the log file name and so forth. You can change them as you like; the only advice I can give you is that the separator I chose it the least probable to occur in an artist name, in a record title or in the speech used to write a note about the record, while other classic separators like : or ; may occur into a title (for instance, axis: bold as love, by Jimi Hendrix).

add2cdd is a useful script that accompanies cdd. It lets you add a line (a record) to your database and after that sort the whole database for quick search. The separator is the same of cdd, since it's defined into custom.data. Here's an example of its usage (in bold the characters you type):

$ add2cdd

You're gonna add records to /Whatever/path/to/cd.db:
enter nothing as the Artist name when you're over.

Artist    : Someone
Title     : Something
Issue year: 1978
CD date   : 2006
Notes     : A record I invented

Artist    :
Inserted and sorted: we're through!

After this program, the record is inserted into the database in lower letters. To check, digit

$ cdd someone

To delete the record you can use any means you like best: an editor, sed, awk or anything else. I provided no scripts for such a task.

Download

last stable version: 1.5.0.

What's new in version 1.5.0 (April 30, 2007)
(I made all sorts of experiments on this script, so the versioning was messed-up. My fault. There's no actual distribution between 1.0.0 and 1.5.0).
previous versions:

1.0.0


What's new in version 1.0.0 (November 25, 2006)
Downloadable files (recommended for any system with bash 3.x):
All versions

You can get all versions and every cdd's project file here (FTP).

It's GPL! Enjoy!