Peters Flexible RenAmiNg Kit (PFrank) Forum Index Peters Flexible RenAmiNg Kit (PFrank)
Support and Discussion Site for the PFrank File/Folder Renaming Tool (http://www3.telus.net/pfrank)
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Complicated subtitle renaming problem

 
Post new topic   Reply to topic    Peters Flexible RenAmiNg Kit (PFrank) Forum Index -> Regular Expressions
View previous topic :: View next topic  
Author Message
martix



Joined: 20 Apr 2007
Posts: 17

PostPosted: Wed Oct 31, 2007 11:43 pm    Post subject: Complicated subtitle renaming problem Reply with quote

Well, you challenge anyone to come up with something PF can't do. Here's my entry.
Ok, I got seven seasons worth of subtitles to rename. Thats a lot of files(~24 per season).
Task: Rename all the subtitles to match the names of the video files. Like - vid name "vid.avi" -> sub name should be "vid.sub"
How to do it:
Directories are named with a prefix and number of season.
Take avi files, first number is the season number(may be one or 2 digits). Second number is always 2 digits(number of episode).
Subtitles are named in diffrent ways but have the same general numbering pattern. So using that find corresponding subtitle and rename it to match its episode.
How's that? Smile

Now I could come up with the regexes eventually(help file should decrease that time to several hours only Razz Very Happy ).
But I have no idea how to make it take data from the directories/video files. No variables or stuff like that to carry it over. I guess User Commands are the key. But I don't know python.
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 446
Location: Canada

PostPosted: Fri Nov 02, 2007 10:05 pm    Post subject: Reply with quote

I don't think you will need to write a user-defined command since there is a way to get video info form video files and to extract info from folder names.
There is also a way to group files for common renaming. However, I won't be sure until I get some specific examples from you.
If you can please supply some before-names and the expected new-names then I'll try to come up with something for you.

Peter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
martix



Joined: 20 Apr 2007
Posts: 17

PostPosted: Sun Nov 04, 2007 3:57 pm    Post subject: Reply with quote

I was out for the holidays, but I'm back now.
Well say folder name is tng-1, video file name is Star Trek TNG - 1x08 - Justice.av and subtitle name is Star Trek TNG [1x08] - Justice [AMC].srt
OR
Folder: tng-5; video file: Star Trek TNG - 5x04 - Silicon Avatar.avi; subtitle: Star.Trek.TNG.S05E04.Silicon.Avatar.DVDRip.DivX-SFM.srt
I hope you got what I want to do...
Back to top
View user's profile Send private message
martix



Joined: 20 Apr 2007
Posts: 17

PostPosted: Sun Nov 04, 2007 4:00 pm    Post subject: Reply with quote

martix wrote:
I was out for the holidays, but I'm back now.
Well say folder name is tng-1, video file name is Star Trek TNG - 1x08 - Justice.avi and subtitle name is Star Trek TNG [1x08] - Justice [AMC].srt
OR
Folder: tng-5; video file: Star Trek TNG - 5x04 - Silicon Avatar.avi; subtitle: Star.Trek.TNG.S05E04.Silicon.Avatar.DVDRip.DivX-SFM.srt
I hope you got what I want to do...

Oops, no edit... I posted too early.
What I meant is that
Star Trek TNG [1x08] - Justice [AMC].srt
should become
Star Trek TNG - 1x08 - Justice.srt - just like the video file's name.
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 446
Location: Canada

PostPosted: Mon Nov 05, 2007 3:42 am    Post subject: Reply with quote

Below is a combo regex and predefined renaming sequence that works for the examples provided. The sequence can be modified/ecpanded as required depending on other variations that may be present in the names.
You should be able to block copy the sequence with the mouse and paste directly into the custom table with CTL-F2 (actually if you block copy this entire reply and insert with CTL-F2, then that should work too!).

=======sequence starts here ================
Row: 1
Search: '(?iEx) [.] # translate dot to blank'
Replace: ' '
Row: 2
Search: '(?xi)DVDRip|\-SFM|Divx # remove these words'
Replace:
Row: 3
Search: 'S[0]*([1-9]+)E([0-9]+)'
Replace: ' - \1x\2 - '
Row: 5
Search: '\[([0-9])'
Replace: ' - \1'
Row: 6
Search: '([0-9])\]'
Replace: '\1 - '
Row: 7
Search: '\-[ ]+\-'
Replace: '-'
Row: 8
Search: '(?Ex) [\{\(\[]+.*?[\]\}\)]+ # remove brackets + contents'
Replace:
Row: 10
Search:
Replace: '*Delete All Extra Whitespace in*Prefix*'

=======sequence ends here ================

Let me know how it works for you.

Cheers,

Peter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
martix



Joined: 20 Apr 2007
Posts: 17

PostPosted: Tue Nov 06, 2007 10:31 pm    Post subject: Reply with quote

Well it does what its supposed to do.
But not exactly what I needed. It did work for some, the others I did by hand eventually...
Now just some discussion. How it should have worked.
1. Use some number data to pair up each video file with its corresponding subtitle.
2. Take the name of video file, without the extension, and apply it to the previously matched subtitle.
So with a folder named "fold-1" and video file "name-1x05.avi" - find the matching sub "blabla s1e05.srt" and replace the italic text with the bolded text.

Now problem is pattern matching works only within the current name. You can't match a pattern in some file and use it to rename another without User Commands I think.
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 446
Location: Canada

PostPosted: Wed Nov 07, 2007 5:51 am    Post subject: Reply with quote

There are a couple of things that can be done.
1) The imperfect but relatively simple solution:
expand the custom list that I gave you to take care of other formats. It should save you lots of time if you can rename the majority of the files.

2) The perfect but complicated solution:
This requires some regex rows similar to row 3 in the sequence I already gave you plus a user-defined command. The regex rows first would massage the season/episode numbers of each name to the same format. The user command would extract the season/episode pair from each name and create 2 hash tables; one for the avi files and the other for the srt files. The key for each table would be the season/episode specifier and the entries would be the episode names.
If we assume that the avi files have the true episode names (is this true???), then at the end of the scan you would have to process the list of srt files and use the key to extract the desired name from the list of avi files.
One problem is that there is no post processing function defined in the user command api. I'll plan to add this in a future release
In the mean-time, a work-around would be to first separate the avi and srt files into separate folders. Name the folders so that the one with the avi files is alphabetically before the one with the srt files. Then run PFrank. When Pfrank processes the files, the avi files will be processed first and the avi hash table can be built completely before the first srt file is processed.
With the avi table completely built, the next files processed will be the srt files which would just extract the titles from the avi table using the season/episode keys.
You could even use the pathbuilder feature in the last row to move the files to folders named after the TV series title and the season number.

If you don't have any programming experience then (2) probably sounds daunting. If you have programming experience, then it should make sense. With Python, hash table creation/processing is trivial.
If I have time, I might be able to whip something up. Otherwise if you would like to give it a whirl I could advise you on what to do. Otherwise suggestion (1) will, hopefully, save you lots of time.

Peter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
martix



Joined: 20 Apr 2007
Posts: 17

PostPosted: Wed Nov 07, 2007 4:58 pm    Post subject: Reply with quote

I adapted the custom list to include the other format and it reduced the work by hand to a handful of files. Which I renamed manually. So now the task is done and no need to worry about it.

Now on a purely technological level:
Perfection is always better than bruteforcing... Smile
The avi's do have the true names, so you're right. I do have some previous programming experience, but not in Python. Though if I took some time to look up a few things, I'm sure I'd manage... Sort of makes sense, I reckon that would work.
On a side note, a search for batch/bulk renaming utilities on Google didn't mention PFrank in any of the beginning pages and being better than even most paid ones I think its a shame. (Suggestion: Do some optimizing) Very Happy Wink
Thanks.

//Martin
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 446
Location: Canada

PostPosted: Thu Nov 08, 2007 3:59 pm    Post subject: Reply with quote

I'm open to making any optimizations especially if it will lead to PFrank being listed on the first page of a Google search!
Did you have any specific optimizations in mind?

If you or anyone else can suggest any improvements then I'm definitely listening Smile

Peter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
martix



Joined: 20 Apr 2007
Posts: 17

PostPosted: Fri Nov 09, 2007 12:05 am    Post subject: Reply with quote

I'm not a specialist in this, but using tons of keywords for example. For all the features. Whatever synonyms you can find. Thats a way I know of. Perhaps there are others, I can do some research when I got time this weekend.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Peters Flexible RenAmiNg Kit (PFrank) Forum Index -> Regular Expressions All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own Video Sharing Site

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com