I just wrote a set of utilities to build a music library or at least to improve an existing one. It is quite specific to my needs, but maybe the convert utility could be reused. It converts between mp3, ogg and flac and copies tags from one file to the other.
This collection of utilities aims at helping in the process of improving the quality of a music library. The music library we are trying to build is made of 2 sets of files in 2 seperate directories: flac and mp3. The 2 directories have the same directory structure, except the mp3 is larger: it contains more files than the flac one.The music library is like this:
flac |- Artist 1 |- Album 1 |- File 1.flac |- File 2.flac ... mp3 |- Artist 1 |- Album 1 |- File 1.mp3 |- File 2.mp3 ... |- Artist 2 |- Album 2 |- File 1.ogg |- File 2.ogg ...
We suppose the library well organized with a directory structure Artst > Album > Files (you have to build it beforehand), and that the flac library and mp3 library have the same directory structures for their common part. The mp3 library is correctly tagged (you have to do it beforehand). The goal is:
- to copy the tags from mp3 files to their flac counterpart.
- to ensure all files in the mp3 directory are .mp3 and are of sufficient bitrate. In order to do this, we either convert from flac, or from ogg if it is possible to do so.
- to build a direcory called best, made of the same directory structure as the mp3 one and containing hard links to the flac files if they exist or else to the mp3 ones.
Command line tools
3 command line tools are included:
Usage: convert [Options] from_file to_file Converts between music files. Accepted file formats are Flac, Mp3 and Ogg. Options: --version show program's version number and exit -h, --help show this help message and exit -t Do not convert files. Copies tag from from_file to to_file -b BITRATE Specifies bitrate for encoding mp3 -v VERBOSE 0: errors, 1: operations, 2: info, 3: debug. Default = 1
Usage: fixmusic [-flac | -mp3] Fixes flac library from mp3 library or the other way round. Options: --version show program's version number and exit -h, --help show this help message and exit --flac Fixes flac library --mp3 Fixes mp3 library -v VERBOSE 0: errors, 1: operations, 2: info, 3: debug. Default = 1
Usage: ./makebest.sh [-n] [-h] -c conf -a action Description: Maintains a directory of music files DIR_BEST by copying the directory structure of DIR_MP3 and linking files from DIR_FLAC if they exist or DIR_MP3 if they don't. All directories and files must exist in mp3 in the first place. Options: -n NOT YET IMPLEMENTED dry-run, do not perform anything on files -h print this help -c NOT YET IMPLEMENTED configuration file -a action to perform, see Actions below Actions: analyse find flac directories not existing in mp3 makebest update directory structure, linking flac if the file exists or else mp3