#!/bin/bash # # mythlink.sh # # Creates readable symlinks referring to MythTV recordings using the # mythrename.pl script ### Modify these values for your installation ### # The path in which the views ("pretty" links) will be created VIEWS_PATH=/mythtv/views # The location of the mythrename.pl script # The default value assumes mythrename.pl is in the user's PATH COMMAND=mythrename.pl ### The following directory names and formats may be customized ### # Formats may be constructed using the format specifiers listed in the # output of "mythrename.pl --help" # Files will be sorted "alphabetically" so the appropriate fields on which you # would like to sort should be placed at the beginning of the format # To add a custom format, simply include a directory name and format in the # environment variables below using the syntax shown below. # The names of the directories containing the views DIRECTORIES=( 'time' 'title' 'group' 'category' 'original_airdate' ) # The formats used for the respective directories specified above FORMATS=( '%Y%m%d-%H%i-%eH%ei-%T-%S' '%T/%Y%m%d-%H%i-%eH%ei-%S' '%U-%T-%Y%m%d-%H%i-%eH%ei-%S' '%C-%T-%Y%m%d-%H%i-%eH%ei-%S' '%T-%oY%om%od-%S' ) # The string used to separate sections of the link name SEPARATOR='-' # The string used to replace illegal characters in the filename REPLACEMENT='_' # Whether to use underscores instead of spaces. # Use '' to allow spaces UNDERSCORES='--underscores' #UNDERSCORES='' # Whether to create links for LiveTV recordings. # Use '' to skip LiveTV LIVETV='' #LIVETV='--live' ### The following should not require changes ### # Ensure word splitting occurs only for newlines as some directory names or # formats may have spaces in their names IFS=$'\n' # Make the links by calling mythlink.pl with the appropriate arguments last_index=$(( ${#DIRECTORIES[@]} - 1 )) for directory in `seq 0 $last_index`; do ${COMMAND} --link ${VIEWS_PATH}/${DIRECTORIES[$directory]} ${LIVETV} \ --format ${FORMATS[$directory]} ${UNDERSCORES} \ --separator ${SEPARATOR} --replacement ${REPLACEMENT} done