MythTV: Give your recordings a human readable filename

NOTE: This guide has been tested on Ubuntu Lucid 10.04, Karmic 9.10, Jaunty 9.04 and Intrepid 8.10 although it may work equally well on earlier or later versions than these.

If you’re going to be streaming your recordings to devices other than a MythTV front-end (for example: a Popcorn Hour, NETGEAR EVA or PS3) then you’ll soon discover that the filenames which MythTV automatically assigns to your recordings are not very user-friendly. Whilst everything works fine if you’re using the MythTV front-end it’s not so if you’re not. Instead of being presented with something meaningful like “Top Gear – 2009-01-10.mpg” to choose from you’ll be presented with a bunch of filenames along the lines of 5671_20090110082000.mpg. Fortunately there is a great little script called mythlink which will solve that problem for us.

The mythlink script is installed as part of the MythTV installation and is located in /usr/share/doc/mythtv-backend/contrib/user_jobs. We need to make sure it is executable before we can use it. So, either from a Putty session or a new Terminal Session from within gnome (Applications -> Accessories) type the following commands:

cd /usr/share/doc/mythtv-backend/contrib/user_jobs

which switches us into the folder where the mythlink script lives and then

sudo chmod a+x mythlink.pl

which makes the script executable.

There are LOADS of different ways of renaming your TV recordings into a more readable form using mythilnk. For a complete list of arguments type:

./mythlink.pl --help

I’ve organised the recordings on my server using ‘Recording Group’ for the main folder. Then within each Recording Group folder I have each ‘Show title’. I then use ‘Recording Date’ for each episode. So for example I see my recordings like this:

  • Childrens (the recording group)
    • Engie Benjy (the show title)
      • 2009-05-10-Far out.mpg (the episode)
      • 2009-05-11-One Step Closer.mpg
      • etc
    • Chucklevision
      • 2009-05-10-Silence is golden.mpg
      • 2009-05-11-On the Hoof.mpg
      • etc
  • Mums
    • Cash in the Attic
      • 2009-05-10-Peter Shilton.mpg
      • 2009-05-11-Frank Carson.mpg
      • etc
    • Desperate Housewives
      • 2009-05-10.mpg
      • 2009-05-11.mpg
      • etc
  • Dads
    • Top Gear
      • 2009-05-10.mpg
      • 2009-05-11.mpg
      • etc
    • Traffic Cops
      • 2009-05-10-Cheating Death.mpg
      • 2009-05-11-Cameras Don’t Lie.mpg
      • etc

I’ve added a Cron Job to run each hour to rename all my recordings. See the Run a script as a cron job using Webmin section for further information on how to set up a Cron Job using Webmin. The script I use to achieve the above can be found here. Download it, rename it to a “.sh” so you know it’s a script and make it executable. So:

mv MyMythRename.txt MyMythRename.sh

to rename the file. It is not actually a requirement for all scripts to end with .sh but I like to use that naming convention so I can tell what a file is without having to open it.

Instead of downloading the script you can create it via Putty:

  • Highlight the whole script, right click and select Copy.
  • Using Putty navigate into the folder where you’re going to store the script.
  • For example type cd /home/xxx/MyScripts where xxx is your username.
  • Next type vim MyMythRename.sh (or your preferred script name) and press Enter. This will open the file for editing.
  • Then press the [Insert] key once and add a couple of blank lines by pressing the [Enter] key. Next right click and the whole script will be pasted into the screen.
  • Then press the [Esc] key once and type :wq to save and quit out of the script. If you make a mistake then issue :q! instead of :wq to abort your changes.

Regardless of how you implement the script don’t forget to make the script executable by typing:

sudo chmod a+x MyMythRename.sh

Organising my TV shows this way works well in my household. So, my children browse to the Childrens folder and then are presented with only their programmes. My wife browses to Mums and gets to see only the programmes she’s interested in and so on. Obviously the above folder structure relies on you assigning relevant Recording Groups when you set up a Recording Schedule. It’s not very intuitive how you set up and maintain recording groups so here’s how: How to add Recording Groups to MythTV