ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Finished Programs

SubDude, a subtitle renaming program

(1/6) > >>

ak_:
Here's a little program i made for myself to automatically rename subtitles files to match video files because i was tired of doing it by hand. I guess this program will not be very useful to english-speaking people but it might be to the others.

Here's the situation : you have a folder containing a few episodes or a whole season of a (100% free to download :-[) tv show. You download subtitles files for it and you realize the names of the of the video files and the names of the subtitles files don't match (ie Serie.s01e12.avi & Serie1x12.srt). If you want your media player to automatically load subtitles, you have to rename every subtitles files by hand.

Now, here's SubDude !

Just give SubDude a folder (by using the gui, context-menu or 'Send to') and he will check every video file and look for a corresponding subtitle, and rename it. If you don't trust SubDude, you can tell him to generate an "UnDude" file so you can revert changes in case things were done the wrong way.

subdude.zip

Known restrictions :

* SongDude assumes all files are from the same season and doesn't check this. Maybe i'll add this in a future version
* If two subtitles files are matching, they will be renamed consecutively so one of them will be crushed (and this won't be undoable)
Any feedback or bug report will be appreciated :)



The ahk source is available here but i'm afraid it's very messy and undocumented.
subdude.ahk

mouser:
clever  :up:

ak_:
Actually, i forgot to say something in my previous message.

To detect episode number, i use regular expressions* based of what i've found in different filenames. Until now, i've seen these templates :


* sseasoneepisode
* seasonxepisode
* EPepisode
* sseason.eepisode
I don't know if many of you use subtitle files, but if you've ever encountered another template, please tell me know so i'll add it in the ini file. Thanks :)

* actually, this project was an opportunity for me to learn about regular expressions and i've been pleased to see that it was less complicated that expected.

Darwin:
Looks good, ak_ My wife's family are Korean and don't speak/read much English: this will help in making video more accessible to them.

 :Thmbsup:

PS What do you use for regex searches (just curious)?

ak_:
PS What do you use for regex searches (just curious)?
-Darwin (August 18, 2007, 11:00 AM)
--- End quote ---
If you're asking which function i use : RegExMatch

I use it once to isolate the season+episode string (like "s01e05", matching the regex "s\d+e\d+" ), then in this string, i isolate the episode number (here "05", matching "(?<=e)\d+" ). I have to do this in two steps (i guess) because :
The bad news is that most regex flavors do not allow you to use just any regex inside a lookbehind, because they cannot apply a regular expression backwards. Therefore, the regular expression engine needs to be able to figure out how many steps to step back before checking the lookbehind.

Therefore, many regex flavors, including those used by Perl and Python, only allow fixed-length strings. You can use any regex of which the length of the match can be predetermined. This means you can use literal text and character classes. You cannot use repetition or optional items. You can use alternation, but only if all options in the alternation have the same length.
--- End quote ---

So i can't look for "(?<=e)\d+" directly on the filename and not expect to get weird results (for example, if the serie's called "AirForce1", the last two letters would match). Maybe there's another solution, i dunno, i just learnt regex yesterday :)

Navigation

[0] Message Index

[#] Next page

Go to full version