Alphanumericalize: Filename munging music file names in ABCDE

Ripping CD feels a lot more 2005 than 2015. And it was probably already starting to feel old back then. However, I never got round to do a systematic, lossless rip of my entire CD collection. So before it’s too late I have bought a DVD-RW drive that will never get to write a single disc and armed myself with a 1Tb USB drive to hold all the data.

My weapon of choice is ABCDE, A Better CD Encoder, a Bash based CLI tool for ripping that has been in continuous development since before 2002 (!). ABCDE has many advantages over GUI CD rippers, the most obvious being that you don’t need to fiddle with the mouse, you just hit enter. This is important if you’ve got a case of hundreds of CDs to get through.

Another advantage is that the settings file allows you to string a piped line of stream editors together when forming the file name. What this means is that once you have determined how the file names should be formed, e.g. “Artist/Album/Track no. – Track title”, you can further manipulate it e.g. by making it entirely lower-/uppercase, removing slashes and other control characters etc. The genius of ABCDE is that rather than implement these features itself, it simply allows you to use tested and true unix utilities, like sed and tr and whatever else you care to throw at it to accomplish this.

Here I’m going to detail generally how this ‘filename munging’ works and specifically I’m going to show how to get file names that are universally OS-, URL- and command line friendly by only using numerical digits, the letters a-z, underscores (_) and hyphens (-).


Resurrecting imwheel

Xmouse for Windows is brilliant. And it makes a mockery of any linux desktop user’s claim to having the more customizable user environment. Well at least as far as pointers go. What Xmouse does is allow you to intercept any mouse action and translate it into any sort of user interaction, be that simply another mouse action, a keyboard action, interacting with the desktop, starting a new program, a mix of the above or (possibly) something else entirely. It has a huge list of possibilities and options, including automatically switching profiles to match the currently running program.

On linux we have a mess of a wiki page with an assortment of hacks. Googling specfic issues result in a similar cocktail of ancient xorg tools, including xkbset, xinput, xmodmap, btnx, xkbe and many more. Now, I’m not one to disparage using old, true and tested tools (see: devilspie, wmctrl) but in this case I believe, it is just poorly documented hacks as X seems to have added ‘pointers’ as somewhat of an afterthought. Poorly worded howtos, barely understood copy-and-paste suggestions and google results stretching back into the mists of time and linux make this a horrible jungle for even experienced linux users. The google problem is compounded by intersecting interests: Some want their mouse to do keyboard inputs, some want them to do commands, some want keyboard keys to serve as mouse buttons, etc.

imwheel has been brought to my attention before but a) the tool seems to have fallen from grace sometime in the previous decade (for one it was dropped from the official Arch Linux repositories and now only resides in the AUR) and b) the man page isn’t really written from the perspective of a user with a specific goal in mind and c) I do believe the semi-gui configuration helper (somewhat similar to xev) isn’t working in today’s desktop environments. So I know that I’ve tried it before and given up – if I even succeeded in building it – concluding that it was probably dead in the water.

Well, Lazarus just got up and walked. The difficulty (for me) lay in the fact that the command line options don’t really hint at how you would want to use it. You have to create a config file but then you can simply run it with ‘imwheel’ and forget about it. As simple as that. This will allow you to intercept mouse actions and get a mixture of mouse and keyboard output that can be made dependent on the currently active program. A somewhat simplistic Xmouse, then. Without the GUI.