Here's a quick and dirty Perl script that I've just knocked up... It just looks in the current directory for .epg files and grabs the episode titles and renames the files with it appended. You should be able to modify it to your own liking as I've commented most of what it does.
#look for all epg files in current directory
@epgfiles = glob("*.epg");
foreach $file(@epgfiles)
{
#open epg file and get programme title and description
open(IN,"<$file") or die "Error: cannot open file $file";
$epg=<IN>;
close(IN);
#get title at specific location (1st entry)
$title=substr($epg,22,49);
$title=~ s/(00+$)//g;
#get synopsis at specific location (1st entry)
$desc=substr($epg,74,254);
$desc=~ s/(00+$)//g;
# grab the first word of title in epg
$title =~ /(\w+)/;
print "EPG title: $1\n";
#if filename matches first word of title then we have the correct synopsis
if($file=~ /$1/)
{
# do nothing
print "matched first entry in epg\n";
}
#else look at the 2nd EPG entry
else
{
# check for next epg entry
print "getting second epg entry\n";
$title=substr($epg,354,49);
$title=~ s/(00+$)//g;
$desc=substr($epg,406,254);
$desc=~ s/(00+$)//g;
# print ">$title<\n>$desc<\n";
}
# search for episode name between '.' and ':'
$desc =~ /\s+([\w+\s*]+):.*/;
print "Episode name: $1\n";
#if episode name exists, rename all files with episode name appended
if($1)
{
@fname=split(/\./,$file);
print "renaming $file $fname[0] $1\n";
rename ("$fname[0].epg","$fname[0] $1.epg");
rename ("$fname[0].elu","$fname[0] $1.elu");
rename ("$fname[0].hre","$fname[0] $1.hre");
rename ("$fname[0].ts","$fname[0] $1.ts");
}
else
{
print "no episode name\n";
}
}
If you want to purchase a renaming program, I highly recommend Flash Renamer (used to be called FlashIt Renamer), currently only about £16. Help this site by buying it via this link.
You can download a functional trial from the Windows Utilities download section.
Obviously, it won't rename the files achieved off the PVR using humaxrw as required above. But it will rename multiple files using rules (capitalise, truncate, search and replace, etc) or using Exif & IPTC tags. So it will be useful for all sorts of renaming, e.g. photos, MP3, etc. Just remember to buy or register it via the purchase links posted here, especially if you download the trial version and decided it is useful...
| Thu 21 Jul 2011 12:14:37
#8 |