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 

Help with renaming fansubs

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



Joined: 15 Apr 2008
Posts: 11

PostPosted: Tue Apr 15, 2008 7:19 pm    Post subject: Help with renaming fansubs Reply with quote

First off I'd like to extend my extreme gratitude for such an incredible program. I only wish I had the aptitude to use it to it's fullest potential. I have been getting better results by just experimenting than I expected, but now I'm stuck.

I keep an extensive collection of anime fansubs of which have wildly variable naming schemes. I wish there was standardization of metadata for all the various video formats, but until then...


This is an example of the format I'm looking for,

Appleseed Ex Machina HD [Movie] (AC3).mkv



The 3 optional variables being parsed from original filename and placed in the order they appear above.

HD = Hd|Hdtv|HiDef|Blueray|BluRay 720p|720i|1080P|1080i (case insensitive)

[] = if Movie|Oav|Ova|Series|Special (case insensitive) Not sure how to notate this but if it parsed any of the terms, it could take the first one it encounters (if more than 1) and insert it between the brackets. Title case for the words but Oav and Ova would both be reformatted to OAV.

() = if Ac3|Dts|Aac (Same as above but using all caps. AC3, DTS, AAC)



So the following example ..

Appleseed_Ex_Machina_(2007)_[1080p,BluRay,x264,Ac3].mkv

would be..

Appleseed Ex Machina HD (AC3).mkv


Here is a small sample of some of the filenames I'm dealing with,


[list=]Azumanga.Daioh.The Movie.DVD(OGG.H264)[GiLgAmEsH].mkv
elfen.lied.oav.h264.anime_fin.mkv
Full Moon wo Sagashite - OVA - .avi
Junkers_Come_Here.DVD(movie)(AAC)[KAA][ECF13FE9].avi
Stormy Night_Arashi_no_Yoru_ni_OVA[x264-vorbis]_[6A3A406E].mkv
Uber_Keroro_Gunsou_Movie_Trailer_[Doremi-Spork][66EE51D3].avi
[Doremi_HF_Shakugan]_Pale_Cocoon_OVA[Xvid][BAEE1167].avi
[DVD]_Sky_Girls_OVA_01.avi
[KAA]_She_and_Her_Cat.DVD_OVA[D88ED2C7].avi
[Megami]_Negima_Haru_-_OVA_[FE5F3698].mkv
[Q-R] BRAVE STORY oav(DVD XviD 704x396 24fps AC3 5.1ch & DTS 5.1ch).mkv
[Shinsen-Dorama]My_Name_Is_Kim_Sam_Soon_oav_[3959494A].mkv
[Shinsen-Subs]_Mars_of_Destruction_OVA_[2C0D8AAA].avi
[Soldats] One OVA - 01.avi
[Triad]_Air_Summer_special_-_02.avi
[Ureshii]Sola_DVD_Special_01[434420EB].avi
[wDr33merz]_Elfen_Lied_extra_ep_14_special_parody_sub.avi[/list]


Now it may be really messy and inefficient, but I've worked out a good bit of it. I'm getting stuck at the stage to rearrange things. As a rule I'd like to work back from the extension so I don't have any extraneous text between my variables and the extension. Some of my rules I insert on the fly when needed like removing version numbers.


My setup,

Row1
Search -
Replace - *Title Case (Also Deletes Extra Whitespace) in*All*

Row 2
Search - (?iEx) [.,\-+_] # translate some chars to blank
Replace -

Row 3
Search - (?xEi)Hd|Hdtv|720[i,p]|1080[i,p]
Replace - RPL01

Row 4
Search - (?xEi)Special
Replace - RPL21

Row 5
Search - (?xEi)Oav|Ova
Replace - RPL22

Row 6
Search - (?xEi)Series
Replace - RPL23

Row 7
Search - (?xEi)Movie
Replace - RPL24

Row 8
Search - (?xEi)Ac3
Replace - RPL31

Row 9
Search - (?xEi)Dts
Replace - RPL32

Row 10
Search - (?xEi)Aac
Replace - RPL33

Row 11
Search - (?x) [\{\(\[]+.*?[\]\}\)]+ # delete brackets + contents
Replace -

Row 12
Search -
Replace - *Title Case (Also Deletes Extra Whitespace) in*All*

Row 13
Search - (?xi)RPL01
Replace - HD

Row 14
Search - (?xi)RPL21
Replace - [Special]

Row 15
Search - (?xi)RPL22
Replace - [OVA]

Row 16
Search - (?xi)RPL23
Replace - [Series]

Row 17
Search - (?xi)RPL24
Replace - [Movie]

Row 18
Search - (?xi)RPL31
Replace - (AC3)

Row 19
Search - (?xi)RPL32
Replace - (DTS)

Row 20
Search - (?xi)RPL33
Replace - (AAC)

Row 21
Search - Episode|Ep|Dvd|Tv|Final|End
Replace -

Row 22
Search - (?E)Xvid|Ac3|Hdtv|h264|H264|avi|Mkv
Replace -

Row 23
Search - (?xi)[v][0-9] #version notation removal 1
Replace -

Row 24
Search - (?xi)([0-9][0-9])(v[0-9]) #version notation removal 2
Replace - \1

Row 25
Search -
Replace - *Delete Trailing Whitespace in*All*

Row 26
Search -
Replace - *Delete All Extra Whitespace in*All*

Row 27
Search - \s(\..*)$
Replace - \1

Row 28
Search - Ova|Oav|ova|oav
Replace - (OVA)

Row 29
Search - (?x) ([^0-9]|^)([0-9])([^0-9]|$) # pad 1 digit number
Replace - \g<1>0\2\3

(Dark red rows turned off)


My Results:
Appleseed Ex Machina (AC3) HD.html
Appleseed Ex Machina (AC3) HD.mkv
Azumanga Daioh the [Movie].mkv
Elfen Lied [OVA] Anime Fin.mkv
Full Moon Wo Sagashite [OVA].avi
Junkers Come Here.avi
Stormy Night Arashi No Yoru Ni [OVA].mkv
Uber Keroro Gunsou [Movie] Trailer.avi
Pale Cocoon [OVA].avi
Sky Girls [OVA] 01.avi
She and Her Cat [OVA].avi
Negima Haru [OVA].mkv
Brave Story [OVA].mkv
My Name is Kim Sam Soon [OVA].mkv
Mars of Destruction [OVA].avi
One [OVA] 01.avi
Air Summer [Special] 02.avi
Sola [Special] 01.avi
Elfen Lied Extra 14 [Special] Parody Sub.avi


I still don't mind hand editing a few file names here and there so if I could just get my order and placement sorted out I'd be quite ecstatic. Sorry for such a lengthy first post. Any help would be most appreciated.
Regards,
Eidolen
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 446
Location: Canada

PostPosted: Wed Apr 16, 2008 2:54 am    Post subject: Reply with quote

Hi,

first off I'd like to congratulate you on what you've done! PFrank was developed with this kind of complex renaming in mind.
Also I appreciate the level of detail since it makes it much easier to interpret what you are trying to do.

If I'm understanding you correctly you would like to take the new names you get from the current custom renaming list, search out everything between square brackets (and probably between parentheses too) and move that enclosed text to the end of the filename prefix.

To do so, add the following after row 29 (copy and paste everything between the single quotes - do not include the single quotes):

Row 30:
Search: '(?Ex)(^.*?)(\[.*?\])(.*) # move square bracketed text to end'
Replace: '\1\3 \2'

Row 31:
Search: '(?Ex)(^.*?)(\(.*?\))(.*) # move parenthesized text to end'
Replace: '\1\3 \2'

You'll have to clean up the whitespace after the swapping.
Hope that helps.

If not, then let me know!

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



Joined: 15 Apr 2008
Posts: 11

PostPosted: Wed Apr 16, 2008 3:50 am    Post subject: Reply with quote

Yikes!
I think I got ahead of myself. I realized I had a flaw in my plan and came here to update my my post when I found you have replied.

First, thank you kindly for the speedy reply. I'm going to wait to try your solutions for now since my flaw would inhibit them anyway. Somehow I overlooked that I am erasing some of the variables I'm trying to save due to the formatting of my sample files.

For example from my sample file list:
[Q-R] BRAVE STORY oav(DVD XviD 704x396 24fps AC3 5.1ch & DTS 5.1ch).mkv


I ended up with:
Brave Story [OVA].mkv

It caught the OVA which made me overlook that it deleted both AC3 & DTS which is a tag I want to keep. (I'm still unsure what to do here. Do I need to create a regex that tries to stop searching once it finds the first term, skipping any other, or try to combine them if I find both.) Not a huge deal and can hand edit if needed as that scenario is very rare.

The rule regex that's messing me up is one I really need.

Row 11
Search - (?x) [\{\(\[]+.*?[\]\}\)]+ # delete brackets + contents
Replace -

My thought on this is to put an exception that deletes all but 'RPL[0-9][0-9]' somewhere after '+.*?' and then my following (rules/lines/regexs/script??) would format them the way I want leaving me with your solution for the end.

I will try to poke around a bit in case you are busy to see what I can do. I have a good idea of what I want but get lost sometimes trying to remember how everything interacts.

Regards,
Eidolen
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 446
Location: Canada

PostPosted: Wed Apr 16, 2008 4:51 am    Post subject: Reply with quote

One trick that I've used in the past is to move special strings to the end of the filename (ie. after the suffix) and surrounding them with some delimiters.
Then later on, I move them back into the prefix into their desired locations. fwiw - That might work for the RPLxx text in this case.

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



Joined: 15 Apr 2008
Posts: 11

PostPosted: Wed Apr 16, 2008 5:26 am    Post subject: Reply with quote

Woot!!
I think I figured it out. Ugly and brute force, but it seems to work. Razz

I pre-empted the offending line with 3 repeating lines moving my variable match to the front of the string till all 3 were in place. I then used your solutions at the end but added a line before the 2 you gave me to place my 'HD' variable.

Killed remaining white space and success!

==========================================================================
Apr 16 2008 05:03:39 ***Scan Complete

'Custom' Replacement Summary:

Row: 1
Search:
Replace: '*Title Case (Also Deletes Extra Whitespace) in*All*'
Row: 2
Search: '(?iEx) [.,\-+_] # translate some chars to blank'
Replace: ' '
Row: 3
Search: '(?xEi)Hd|Hdtv|720[i,p]|1080[i,p]'
Replace: 'RPL01'
Row: 4
Search: '(?xEi)Special'
Replace: 'RPL21'
Row: 5
Search: '(?xEi)Oav|Ova'
Replace: 'RPL22'
Row: 6
Search: '(?xEi)Series'
Replace: 'RPL23'
Row: 7
Search: '(?xEi)Movie'
Replace: 'RPL24'
Row: 8
Search: '(?xEi)Ac3'
Replace: 'RPL31'
Row: 9
Search: '(?xEi)Dts'
Replace: 'RPL32'
Row: 10
Search: '(?xEi)Aac'
Replace: 'RPL33'
Row: 11
Search: '(.*?)(RPL[0-9][0-9])'
Replace: '\2 \1'
Row: 12
Search: '(.*?)(RPL[0-9][0-9])'
Replace: '\2 \1'
Row: 13
Search: '(.*?)(RPL[0-9][0-9])'
Replace: '\2 \1'
Row: 14
Search: '(?x) [\{\(\[]+.*?[\]\}\)]+ # delete brackets + contents'
Replace:
Row: 15
Search:
Replace: '*Title Case (Also Deletes Extra Whitespace) in*All*'
Row: 16
Search: '(?xi)RPL01'
Replace: 'HD'
Row: 17
Search: '(?xi)RPL21'
Replace: '[Special]'
Row: 18
Search: '(?xi)RPL22'
Replace: '[OVA]'
Row: 19
Search: '(?xi)RPL23'
Replace: '[Series]'
Row: 20
Search: '(?xi)RPL24'
Replace: '[Movie]'
Row: 21
Search: '(?xi)RPL31'
Replace: '(AC3)'
Row: 22
Search: '(?xi)RPL32'
Replace: '(DTS)'
Row: 23
Search: '(?xi)RPL33'
Replace: '(AAC)'
Row: 24
Search: 'Episode|Ep|Dvd|Tv|Final|End'
Replace:
Row: 25
Search: '(?E)Xvid|Ac3|Hdtv|h264|H264|avi|Mkv'
Replace:
Row: 26
Search: '(?xi)[v][0-9] #version notation removal 1'
Replace:
Row: 27
Search: '(?xi)([0-9][0-9])(v[0-9]) #version notation removal 2'
Replace: '\1'
Row: 28
Search:
Replace: '*Delete Trailing Whitespace in*All*'
Row: 29
Search:
Replace: '*Delete All Extra Whitespace in*All*'
Row: 30
Search: '\s(\..*)$'
Replace: '\1'
Row: 33
Search: '(?Ex)(^.*?)(HD)(.*) #move "HD" to end'
Replace: '\1\3 \2'
Row: 34
Search: '(?Ex)(^.*?)(\[.*?\])(.*) # move square bracketed text to end'
Replace: '\1\3 \2'
Row: 35
Search: '(?Ex)(^.*?)(\(.*?\))(.*) # move parenthesized text to end'
Replace: '\1\3 \2'
Row: 38
Search:
Replace: '*Delete All Extra Whitespace in*All*'

Current Folder: 'O:\ANIME\Karas'
Name Filter (Unix Wildcard match for patterns):
Types: Files Only Name Filter: '*'
Date Exclusion: Disabled Name Exclusion Filter: None
Min Name Length: 001 Max Name Length: 256 Min Path Length: 001 Max Path Length: 256
Subfolder Levels: 256 Subfolder Filter: '*'
Subfolder Exclusion Filter: None

Total Names to be Changed: 6
Total Names Scanned (after Filtering): 6

==========================================================================

Before:
Karas - 02 (DVD, AC3, OGG)[Nyanko][2C6F13AA].mkv
Karas - 03 (DVD, ac3, 1080p)[movie][5FBFDC94].mkv
Karas - 04_[Ani-Kraze]_[DVD-AC3].mkv
[Ani-Kraze]_KARAS_-_05_[DVD-AC3]_[51686410].mkv
[Ani-Kraze]_KARAS_-_06_[FINAL]_[DVD-AC3]_[ED1AECBA].mkv
[Oni]Karas_III_Revive ac3 [4740A5D7].mkv

After:
Karas 02 (AC3).mkv
Karas 03 HD [Movie] (AC3).mkv
Karas 04 (AC3).mkv
Karas 05 (AC3).mkv
Karas 06 (AC3).mkv
Karas III Revive (AC3).mkv


Thank you again so much. I have a little more confidence now with your help that I think I can make most of what I need. What I like the most is the ability for brute force attacks on renaming without having to have an elegant solution. I'm sure my fix would make most programmers giggle, but I couldn't be happier.

Cheers to you!
Eidolen

P.S. Thanks for the copy&paste tip as well. I knew I had to be overlooking something.
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