Well actually, I worked out another way. And now that I read back through the posts, it's exactly the way Mr.Noodle said. Go figure.
Simple enough for anyone that has any programming knowledge.
Easier still for anyone that likes my naming style and wants to copy/paste.
And it takes a step (automater) out of the process.
I just created, I don't know what it's called, an action maybe, something that hazel does when the rules match, and chose 'run shell script'. Then leave the second column default and click on edit script.
Change the first line to /usr/bin/perl and put this code in the big box:
- Code: Select all
#!/usr/bin/perl
$name = @ARGV[0];
$oldname = $name;
# Change episode numbers
$name =~ s/(\.S0(\d)E(\d\d))?(?(1)|\.S(\d\d)E(\d\d))/ - \2\4x\3\5 -/g;
# Remove release information
$name =~ s/(\.HDTV)|(\.PDTV)|(\.WS)|(\.DSRip)|(\.XviD)|(\-LOL)|(\-2HD)|(\-aAF)|(\-0TV)|(\-DOT)|(\-FQM)|(\.\[VTV\])|//g;
# Replace all periods with a space ignoring the filetype
$name =~ s/\.(?!\w\w\w?\w?$)/ /g;
system("mv", $oldname, $name);
Works like a charm. However, there is still some tinkering to be done with the regular expressions because not everything was caught. Some of the episode numbers were formatted so the regexes didn't catch them. And a few of the episodes actually had spaces in the them so the release information wasn't caught. But it's working enough right now (catches most of them) that I'm happy. When it starts bugging me again or if I just get some time, I'll fix those bugs.
Or if anybody else is good with regex, give it a go.
Disclaimer: I'm not a perl programmer. While this does work, I can't say if it's the best way possible