tvrenamer.exe depending on which version you downloaded
Here you'll find a little program which can rename your video collection for you, it has the following nifty features:
Note: No longer using version numbers, as project is now hosted on GitHub.com and only receives bug-fixes, not major new features.
Found a bug? Please report it at https://github.com/meermanr/TVSeriesRenamer/issues
There are two flavours of the script, the normal Perl script which works on any computer which has the Perl scripting language installed on it, and a special Windows-only executable. If you don't know which one to download, try the Windows-only one, it won't bite.
Works on any platform which has the Perl scripting language installed. Perl comes pre-installed with most Linux distributions and Mac OS X, if you don't have it you can get it readily from perl.org
My last installation of Windows corrupted itself, and I've no intention of fixing it. I rely on the kindness of others to compile these binaries. Big thanks to Danny Fallon for donating the current version!
A special Windows-only version, which is created out of the Perl script proper above. It's a much bigger download, and is known to have some minor glitches, but it doesn't require you to have Perl installed.
tvrenamer.pl. Rest assured that this version (
tvrenamer.exe) works identically.
Please skim over this page to get an idea of how to use the script effectively, and email me if you have any comments / suggestions and what-not!
This section is a “least you need to know” approach to documentation. Once you're familiar with the basics you may want to check the advanced section to see all that you can achieve with the script!
Group your videos into folders, one season per folder. Name the folder like this:
Now to run the script. Move the script1) into the same folder as your videos and run it by double-clicking.
The script may take about 10-15 seconds to load, and then you should see it something like the following:
Detected series name 'Smallville' (Season 6) Reading input in AutoFetch mode from EpGuides.com Fetching document ... [Done] Generating changes... Proposed changes: ____________________________________ Smallville 6x01 - Zod.avi Smallville 6x02 - Sneeze.avi Smallville 6x03 - Wither.avi Smallville 6x04 - Arrow.avi Smallville 6x05 - Reunion.avi Smallville 6x06 - Fallout.avi Smallville 6x07 - Rage.avi Smallville 6x08 - Static.avi Smallville 6x09 - Subterranean.avi Smallville 6x10 - Hydro.avi Smallville 6x11 - Justice.avi Smallville 6x12 - Labyrinth.avi Smallville 6x13 - Crimson.avi Smallville 6x14 - Trespass.avi Smallville 6x15 - Freak.avi Smallville 6x16 - Promise.avi Smallville 6x17 - Combat.avi Smallville 6x18 - Progeny.avi Smallville 6x19 - Nemesis.avi Smallville 6x20 - Noir.avi Smallville 6x21 - Prototype.avi Smallville 6x22 - Phantom.avi ____________________________________ Would you like to proceed with renaming? [y/N/?]:
Press “Y” and you're done!
It's always good to know how to approach a problem. When you find the script isn't doing exactly what you want, try the built-in help for a list of options:
Some series, notably Southpark, number their files without a gap between the season number and the episode number. For example, “1005.avi” is season 10, episode 5. The script will read this number as episode “1005” of whatever season it thinks the folder is2). To correct this, use:
This will make the script use only the last 2 digits of a number in the file name as the episode number, using the rest as the season.
The script tries to make as few assumptions as possible, which means that if the data it found on the web for your series only lists, say, 6 episodes of a 22 episode series it cannot know that the series will eventually be 22 episodes. It works on what it knows to be true and in this case that means: “There are 6 episodes”. So it considers a single-digit number to be sufficient.
If the website was updated to list the first 10 episodes, then the script would think “Ah, I'm going to need more space for the numbers” and will pad the single-digit numbers with zeros. This scales well: When I rename my 260+ episode series, it pads the numbers so they are all 3-digits long.
However, you can override this if you like. Just tell the script how many digits you want your numbers to be:
If you see a lot of nonsense, such as “←[31m”, try the
--noANSI option when you run the script. This disables fancy text formatting, such as using colour etc.
“ANSI” is the colloquial term for ANSI Escape Codes, which is a way of displaying coloured text. If you have ever dabbled in HTML it's a bit like a <font> tag which is hidden from sight but magically changes the way text is displayed.
DOS doesn't natively support ANSI escape sequences, but if you install the Perl module
Win32::Console::ANSI you need only comment-in a line near the top of the script to enjoy colour.
Remove the “#” infront of this line:
#use Win32::Console::ANSI; # Hack to fix up Win32 console to support ANSI (http://www.bribes.org/perl/wANSIConsole.html#dl)
Because I'm in a bit of a rush, here is the latest email I wrote answering this question (also, see below for an even better solution):
Of course the simplest answer is to make shortcuts instead of copying, but that doesn't really solve the problem - it's a manual step for each folder!
> Hello, > > Thank you for your script. It really helps me. You're very welcome! :-) > I have two questions: > > 1. Is it possible to specify another path than default one? At this moment I > must copy the executable tvrenamer.exe to all my folders or change my PATH > variable. Not exactly. I plan to add that feature in v3 which I am working on at the moment, but it's going to be a while before it is ready. However, it sounds like you are using Windows and there is a special feature for windows you may like! The script has the ability to "install" itself on your PC such that when you right click on a folder in explorer one of your choices is "Use TVrenamer script". To install this feature, copy tvrenamer.exe to your desktop and then open a command prompt like so: START > RUN > "cmd.exe" > OK This should open a black window where you can type in commands. Change to your desktop directory with "cd Desktop" <ENTER> Now run the script like so: "tvrenamer.exe --associate-with-video-folders" <ENTER> This should print some text telling you all went well. Try right-clicking a folder in explorer, you should see a new option "Use TVRenamer script". If it doesn't work please let me know, with as much info as you can spare on what you did and what sort of system you are using. Also a hint at how tech-savvy you are would be helpful when I write my response. You can uninstall this feature like so: "tvrenamer.exe --unassociate-with-video-folders" Good luck! - RobM
I got a better solution to this problem from Dave (thanks!):
>Hi Robert, > >Thanks for this great app, its been very handy for me. > >I noticed on your site there's a section with "Can I rename folders without having to copy tvrenamer.exe all the time?" >Your answer, while it works, means you can't enter extensions to the exe. > >An easier way of solving this problem is for a user to place a copy of tvrenamer.exe in their windows/system32 folder. >Then they can just type tvrenamer.exe in any folder and it will pick it up. >This has been working for me, and is a simple way without having to copy it into each folder. > >Regards, >Dave
..and then Adrian sent me a script he uses, which finds the directories for you! Thanks very much Adrian!
> I have a script that I run regularly to scan through the TV Shows > directory on my NAS. The script runs tvrenamer.pl on any likely > looking directory (assuming a directory structure such as > "Programme/Series x" or "Programme/Season x" where x is a numeric > value). The script is very rough and ready and looks like this: > > #!/bin/sh > cd /Volumes/video/TV\ Series > IFS=$'\n' > for dir in `find -E . -type d -iregex "./[^/]*/S(eason|eries)[[:space:]]+[0-9]+"`; do > ( cd "$dir"; rm -f ._*; tvrenamer.pl --unattended; ) > done
You can create a preferences file, which
tvrenamer.exe will read every time you run it. This file contains all the options you might want to include on a command line or in a shortcut, without the hassle of actually including them.
First you need to create an empty text file with a special name that Windows doesn't usually like (sorry, the script was originally written for Linux). Create the file like so:
START > Run > "cmd.exe" > OK "echo. > .tvrenamerrc" <ENTER> "notepad .tvrenamerrc" <ENTER>
This should pop up notepad with an empty file. Enter text so that the file contains the commands you want to appear by default, one per line. For instance, if you didn't want it to ask you for confirmation, you could add:
and then save it. Now when you run
tvrenamer.exe it should not prompt you to answer any questions, and will assume “Yes” to renaming, and “No” to any other questions (to make sure it doesn't trash your files by doing something weird).
tvrenamer.exe only looks in your “home” directory3), which happens to be where new command-prompts start in.
.tvrenamerrc file — this breaks the script. When
.tvrenamerrc is read in, each line will have double-quotes added around it, so you don't need to!
(In order of appearance)
Sar: Seriously, thanks for making your work available; I think this has to be the third most useful software tool I've used to further my anime-watching experience, the other two being the media player and the download tool. Messily-named files wind me up something rotten.
TonyW: Thanks for this superb little script (Tv episode file renamer)!
Rolf: I found your rename script today and tried it on a couple of episodes. Simply awesome!
TonyJ: This script is absolute gold! I thought about doing a similar thing in ruby, but this works a treat!
Zhen: Keep up the good work
JesusG: Very impressed with your script!!! It's become a essential in my software favourites. Thank you very much
BrockH: I like your renaming script… only downloaded it tonight, but it's worked fine on the couple of series I've run it on.
PhilS: First of all, great script! Love it. Took me a while to setup my .tvrenamerrc but it's all looking good now.
DavidA: First off, I'd like to thank you for a great script. I've been looking for something like this for a while now.
GeoffA: First just wanted to say thanks for the tv renamer script. It's something I've been wanting for a very long time but had never bothered looking for since I didn't really think anyone had written one. I actually stumbled on it completely by accident.
If you want to speak louder than words, I invite you to donate something - but please, don't feel you have to! I maintain this script because I enjoy it!
If you are having problems, and skimming the manual and trouble-shooting doesn't help, don't hesitate to find me online (but please mention the script or I might think you're spam!) or send me an email:
I want the manual to explain all aspects of the script in an accessible manner. In practice this means I intend to document the effects of all options available to the script, with lots of examples.
This script started back in late 2001 as a one-line Perl command that removed the word “Chapter” from every file in the current directory. Back then I didn't know any Shell-scripting or Perl, so that was my first Perl script ever!
Perl and it's regular expressions intrigued me, so I spent some time reading the Linux man pages and eventually set myself the challenge of making a script that could rename every file in a folder using a list of desired filenames.
It's been evolving ever since, and now sports some rather nifty features!
If you are using the Perl script proper (
tvrenamer.pl) you need to have Perl installed, and have the following modules available (all available through CPAN):
If you are using the Windows-only build, then you only need Windows.
This script takes episode title data as input and tries to match it to the files present in the current directory. For this to work properly both the episode data you feed it, and the filenames need to be in a format that the script can understand.
There are multiple ways of feeding the script episode titles you want applied to the file in the current folder:
Normally you will want to use the last method, as it is the most convenient and works in most cases. Below I will explain how to use the various methods with any tips that come to mind, as well as some examples.
This was the first mechanism the script had for getting data. It may still be useful in modern versions because it is less susceptible to cosmetic changes in a website than some of the modern parsers.
Invoke this mechanism by passing the “-” option to the script:
You should see something like the below:
Detected series name 'Smallville' (Season 6) Reading input in AutoDetect mode from STDIN (Press ^D to end):
Now you goto one of the supported websites (see
tvrenamer.pl --help for a list) and copy the episode data to the clipboard, then paste it into the terminal you are running the script in. Press return a couple of times to make sure you're on a new blank line, and then press CTRL + D to signal you're done pasting text.
For example, I would paste the following data from http://epguides.com/Smallville:
111. 6- 1 2T7701 28 Sep 06 Zod 112. 6- 2 2T7702 5 Oct 06 Sneeze 113. 6- 3 2T7703 12 Oct 06 Wither 114. 6- 4 2T7704 19 Oct 06 Arrow ...
The script ought to then suggest the following:
Proposed changes: ____________________________________ Smallville 6x01 - Zod.avi Smallville 6x02 - Sneeze.avi Smallville 6x03 - Wither.avi Smallville 6x04 - Arrow.avi ...
This mechanism is useful for off-line renaming because the script does not need to contact a website to obtain the episode titles.
Same as the previous section, except you save the episode title data into a text-file which you must place in the same directory as your videos, and name specially using the website lists in
tvrenamer.pl --help. For instance, the built-in help contains the following line:
--EpGuides Assume input is in http://www.EpGuides.com format
So you would name the text-file
EpGuides.txt, although the case is not important. To use this text file you would simply run the script in the current directory, and it will pick it up.
: It shouldn't be necessary to give the text-file a special name.
This is perhaps the second most useful mechanism, it's handy for when the script is having a retarded moment and cannot work out what your series is called.
Find the page on one of the supported websites (see the list in
tvrenamer.pl --help) which lists all the episode titles, and provide this link to the script on the command line. Be sure to include the quote marks on Linux and Mac OS X! 5)
By far the most convenient mechanism, when it works. I'm always looking to add support for more websites, so let me know if the script isn't compatible with your favourite site!
As this is the default behaviour, you do not need any arguments to the script:
/media/anime/Complete/One Piece is an anime, and
/media/Complete/One Piece is not. See the --search option.
For this mechanism to work you need to make sure the script has the “correct” name of the series in mind when searching. “Correct” here means that it matches what the website says. For example the recent Dr Who series is called “Doctor Who 2005”, even though I prefer to think of it as “Dr Who 27x”.
Either rename the folder to match the website, or amend the script's behaviour using some of the advanced options which are described later. For completeness here is how I tackled the above Dr Who problem: I kept my folder called “Dr Who 27x” and used the following command:
tvrenamer.pl --series=DoctorWho_2005 --season=1 --postproc='s/DoctorWho_2005/Dr Who/;s/ 1x/ 27x/'
How does this work?
--series= switch overrides the name which is normally taken from the folder's name.
--season= switch again overrides the season which is normally taken from the folder's name.
--postproc= switch is a highly advanced one which allows me to inject some Perl script for this run only. I've specified two substitutions:
s/DoctorWho_2005/Dr Who/ which replaces the first occurrence of “DoctorWho_2005” in the new filename with “Dr Who”.
s/ 1x/ 27x/ which replaces the first occurrence of “ 1x” in the new filename with “ 27x”.
--postproc- the script would suggest new filenames like this:
DoctorWho_2005 1x01 - Rose.avi DoctorWho_2005 1x02 - The End of the World.avi ...
--postproc= I get this:
Dr Who 27x01 - Rose.avi Dr Who 27x02 - The End of the World.avi
As I wrote the script, it pretty much always works for me. So I need your help making this bit useful, if you have a problem getting to run please email me, even if you don't much care about making it work and will never return to my site! If you encountered a weird problem and managed to fix it yourself, please also let me know so others can benefit from your solution!
To report a problem, email email@example.com, including a problem description and output log (or screenshot if you don't know how to log output).
In the meantime, here are somethings to check:
Do you have all of the following Perl modules installed?
You can install these modules using the
cpan command. You can think of it as a Perl package manager. Run the following command from a command-prompt:
cpan Switch Term::ReadKey Cwd LWP URI::Escape Compress::Zlib File::Glob Text::Unaccent
Additional command for Windows (these are needed to work around Unicode issues)6):
cpan Win32API::File Encode
You may need to convert the file from DOS line-endings to Unix ones. Popular utilities for this are “fromdos” and “dos2unix”.
--series=anime or explicitly avoided with
--scheme= option detailed below)
--noautoranging) — this takes care of “specials” on TV.com
--dubious command-line argument to detect this as 1×08, instead of 1×108)
--ANSI). If you see gibberish on your screen, disable this with
--cache), which creates a
.cache file — this is useful if you want to experiment with different settings, or are debugging / altering the script.
The script makes a few assumptions about your setup:
It also makes a few assumptions in an attempt to be helpful (these can be overridden):
AniDB.txt is in the current directory, it uses it as input, reading it as AniDB data.
TVtorrents.txt is in the current directory, it uses it as input, reading it as TVtorrents data.
TVtome.txt is in the current directory, it uses it as input, reading it as TVtome data.
TV.txt is in the current directory, it uses it as input, reading it as TV.com data.
TV2.txt is in the current directory, it uses it as input, reading it as TV.com “All Seasons” data.
EpGuides.txt is in the current directory, it uses it as input, reading it as EpGuides data.
Subscribe Changes button at the bottom of this page.
tvrenamer.exe depending on which version you downloaded
C:\Documents and Settings\username