Just spent a bit of time hacking out a little script to do a basic copy of
TV recordings from my live recording drive (this is MythTV) to my video
drive. It was just _so_ easy, even though I'm way rusty.

Now Gus is gonna come back and say "why didn't you use mytharchive?" but I
have my reasons, Gus (not the least of which is, my script works and
sometimes mytharchive less-than-works).

Ya know, now that I think of it, most of Myth is a
wrapper-that-talks-to-a-database. If it had been up to me, I'd have
written the whole damned UI in Tcl/Tk, saved a lot of time, and given the
world better access to improving it.

Here's my little script for grins:

#!/usr/bin/tclsh

# set some directories -- edit here for your system
# dir with the recorded tv shows
set tv_dir "/data/myth/tv"
# assumes the preferred renaming in a show_names subdir
set tv_name_dir "$tv_dir/show_names"
# destination dir for videos
set video_dir "/data/myth/video"

# get the command line arg
set MoveNameGlob [lindex $argv 0]

# process the name in .../show_names for the name in the video dir
# take out spaces (personal prejudice) and cut out date-time string
proc fixName {OldName} {
        set Name [file tail $OldName]           ;# chop off the lead dir part
        regsub -all {\s} $Name _ Name           ;# take out spaces
        regsub -all {_-_.*_-_} $Name _ Name     ;# cut out date-time string
        return $Name
}

# main processing loop
foreach ShowName [glob -directory $tv_name_dir -nocomplain $MoveNameGlob] {
        # fix the new name
        set NewName [fixName $ShowName]

        # Print a helpful progress message
        puts "Now processing $NewName"

        # find the real name
        set RealName [file link $ShowName]

        #  COPY the real name file to the new name in .../video --
        # delete through Myth to clean up database
        file copy -force $RealName $video_dir                   ;# copy
the file over (same name)
        set RealNameRoot [file tail $RealName]
        file rename -force $video_dir/$RealNameRoot $video_dir/$NewName ;#
rename it in place
}

# ... and an all done msg
puts ""
puts "THAT'S ALL FOLKS!"


-- 
Lan Barnes

SCM Analyst              Linux Guy
Tcl/Tk Enthusiast        Biodiesel Brewer

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to