Go to TogaWare.com Home Page. GNU/Linux Desktop Survival Guide
by Graham Williams
Duck Duck Go

Audio Filenames

20190818 An audio collection can be maintained using a very structured format for the folder hierarchy and filenames. A suggestion is:

  <artist>/<year>_<album>/<track>_<title>.(flac|ogg|mp3)
  <artist>/<year>_<album>/cover.jpg

All names are lower case and the year is four digits whilst the track is two digits. In this way the database of audio is maintained ordered by the artist. Within the artist's folder their albums are ordered chronologically. The individual tracks are then ordered numerically.

The scheme uses underscore everywhere rather than hyphens. The initial number (year or track) of the file name is always readily recognisable and hence separating it from the title with an underscore does not introduce any ambiguity. An underscore is more consistent and generally automatic.

The rename command introduced in Chapter 18 is very helpful in renaming files. It makes considerable use of regular expressions. As a simple example, hyphens in a filename can be readily substituted by underscore globally across the file name using:

$ rename -v 's|-|_|g' *
The -v turns on verbose mode so that the actions taken can be observed.

The rename command is a powerfull tool and the following may be useful, but represent just a starting point:

$ rename -v 's|(^.*)|\L$1|' *		# To lowercase.
$ rename -v 's| |_|g' *		        # Replace spaces.
$ rename -v 's|_-_|_|' *                # A common pattern to fix in song names.
$ rename -v 's|&|and|g' *           	# Expand the symbol.
$ rename -v 's|^(\d\d)-|$1_|' *    	# Replace 01-paradise.mp3 with 01_paradise.mp3
$ rename -v "s|[~]|_|g" *               # Replace miscellaneous characters.
$ rename -v 's|\.\.+|_|g' *           	# Remove multiple periods.
$ rename -v 's|_+|_|g' *           	# Remove multiple underscore.
$ rename -v "s|['\(\)\[\]\`,\!]||g" *   # Remove unwanted characters.
  
$ rename -v 's|_roger_watson||' *  	# Remove common strings.


Support further development by purchasing the PDF version of the book.
Other online resources include the Data Science Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 1995-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.