Keeping tags like REPACK,PROPER...

Any questions? Need some help?
Post Reply
seriezman
Posts: 5
Joined: 03 May 2012, 20:57

Keeping tags like REPACK,PROPER...

Post by seriezman »

I use following format for renaming TV series.

Code: Select all

{n.space('.')replacePart(replacement = "Part")}.{s00e00}.{t.space('.')}.{source}.{vc}-{group}
for example ,
i got a file like this
Serie.Name.S01E02.PROPER.HDTV.XviD-GROUP

after rename
Serie.Name.S01E02.Episode.Title.HDTV.XviD-GROUP

proper tag is gone.is there a way to keep tags like PROPER , REPACK ,RERiP ?
User avatar
rednoah
The Source
Posts: 19139
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Keeping tags like REPACK,PROPER...

Post by rednoah »

Naming Scheme:

Code: Select all

{fn.match(/(?i)proper|repack|rerip/)}
:idea: Please read the FAQ and How to Request Help.
Igor
Posts: 14
Joined: 27 Jun 2012, 21:04

Re: Keeping tags like REPACK,PROPER...

Post by Igor »

The only problem with that is if you have a release that is both a proper and a repack for instance, then you will only get the first tag that is encountered.

I use a naming scheme that is very similar to yours.

My full naming scheme is:

Code: Select all

{n.upperInitial().space('.').replaceAll(/[,()]+/).replaceAll(/\.-\./,'.')}.{s00e00}.{t.upperInitial().space('.').replaceAll(/[,]+/)replaceAll(/\.-\./,'.').replacePart('Part.$1')}{"."+fn.match(/(?i:unrated)/).toLowerCase().upperInitial()}{"."+fn.match(/(?i:uncut)/).toLowerCase().upperInitial()}{"."+fn.match(/(?i:extended)/).toLowerCase ().upperInitial()}{"."+fn.match(/(?i:internal)/).toUpperCase()}{"."+fn.match(/(?i:proper)/).toUpperCase()}{"."+fn.match(/(?i:repack)/).toUpperCase()}{(dim[1]>480 &&  dim[0]==1280) ? '.720p' : (dim[1]>720 && dim[0]==1920) ? '.1080p' : null}{".$source"}{"."+vc.replaceAll(/AVC/, "H264")}{'-'+fn.replaceAll(/$n/,n.replaceAll(/ [-]/,'.')).match(/(?:(?<=[-])(?!(cd|CD)[0-9]+)\w+$)|(?:^(?!(cd|CD)[0-9]+)[A-Za-z0-9]+(?=[-]))|(?:(?<=^[\[])[^\]]+(?=[\]]))|(?:(?<=[\[])[^\]]+(?=[\]]$))/)}
I do look for each of the tags seperately, that way they are still included if there is more than one.

Code: Select all

{"."+fn.match(/(?i:internal)/).toUpperCase()}{"."+fn.match(/(?i:proper)/).toUpperCase()}{"."+fn.match(/(?i:repack)/).toUpperCase()}
I don't currently look for rerip but it's easy enough to add. I'm not sure if there's a way to simplify that and keep the functionality of retaining multiple tags.

Anyway my naming scheme looks long and confusing but it works quite well and handles several special cases, so give it a try because I get the feeling you are trying to achieve the same result.
seriezman
Posts: 5
Joined: 03 May 2012, 20:57

Re: Keeping tags like REPACK,PROPER...

Post by seriezman »

Thanks so much for the replies.
Igor , you got it right. That's absolutely what I want.Your format does a clean job and as you said handles special cases.This renaming thing became an obsession on me:) . I really mind the smallest details and want to build a standart for renaming.This will help A LOT.I want to get into this job a bit more.Is there a guide or something for learning how to write a naming scheme? I actually want to know what everthing you write means and add something maybe.
Thank rednoah for this program and you for the format.(sorry for my English)
Igor
Posts: 14
Joined: 27 Jun 2012, 21:04

Re: Keeping tags like REPACK,PROPER...

Post by Igor »

There's some info here:

http://filebot.sourceforge.net/naming.html

Also here:

http://filebot.sourceforge.net/forums/v ... hp?f=5&t=2

The code for matching patterns, like you find in the .replaceALL() or .match() functions, is called a "Regular Expresson" or "RegEx" and some info about it can be found here:

http://www.regular-expressions.info/tutorial.html

As for my naming scheme I will break it down for you here.

Code: Select all

{n.upperInitial().space('.').replaceAll(/[,()]+/).replaceAll(/\.-\./,'.')}
The n is the name of the show as retreived by FileBot.
.upperInitial() takes that name and capitalizes the first letter of every word.
.space('.') replaces all spaces in the name with periods.
.replaceALL(/[,()]+/) removes all commas and parentheses.
.replaceAll(/\.-\./,'.') removes dashes in the name.

Code: Select all

.{s00e00}
This adds the season and episode numbers in the format s00e00. This is an inbuilt format that handles many special cases and even single files with multiple episodes, e.g. s01e01-e02.

Code: Select all

.{t.upperInitial().space('.').replaceAll(/[,]+/)replaceAll(/\.-\./,'.').replacePart('Part.$1')}
t is the title of the episode as returned by the FileBot match.
Once again we are capitalizing the first letter of each word, replacing spaces with periods, removing all commas and replacing dashes with periods.
.replacePart('Part.$1') is a built in function that detects if the episode has multiple parts and formats them according to the pattern between the single quotes.
Part.$1 Part. is literally that text, and the $1 is a placeholder for any number.

Code: Select all

{"."+fn.match(/(?i:unrated)/).toLowerCase().upperInitial()}{"."+fn.match(/(?i:uncut)/).toLowerCase().upperInitial()}{"."+fn.match(/(?i:extended)/).toLowerCase ().upperInitial()}
These are all used to detect special types of episodes, unrated, uncut or extended.
fn is the original file name.
.match(/(?i:unrated)/) simply matches the regex pattern, in this case (?i:unrated), and returns it.
The regex in this case is very simple. (?i:unrated) the () group the expression, the ? denotes that the group should not return a backreference (check the regex link above for what that means, and the i means that the search is case insensitive, and unrated is literal.

Putting the "." inside the curly braces means that if no match is found by the above nothing is inserted into your filename, no left over period, or space or anything.

.toLowerCase() simply changes the returned match to lower case.

And then as above we capitalize the first letter.

Code: Select all

{"."+fn.match(/(?i:internal)/).toUpperCase()}{"."+fn.match(/(?i:proper)/).toUpperCase()}{"."+fn.match(/(?i:repack)/).toUpperCase()}
Same as above but this time I just capitalize ALL the letters of the returned match. This is just a personal preference of mine.

Code: Select all

{(dim[1]>480 &&  dim[0]==1280) ? '.720p' : (dim[1]>720 && dim[0]==1920) ? '.1080p' : null}
This is my own code for determining if content is in HD format. There are a couple of inbuilt ways of doing it in FileBot but I found I was getting some false positives.

This basically checks the dimensions of the video. If the height is greater than 480px and the width is equal to 1280px it marks the file as 720p. Or if the height is greater than 720px and the width is equal to 1920px then it marks the file as 1080p. Otherwise it does nothing.

Code: Select all

{".$source"}
Built in function that returns the source, e.g. DVDRip, HDTV, etc.

Code: Select all

{"."+vc.replaceAll(/AVC/, "H264")}
vc returns the video codec as determined by FileBot.
replaceAll(/AVC/, "H264") is sort of a personal preference of mine. I noticed that many of my HD scene files that were marked as H264 were detected and marked as AVC by FileBot. While that is probably more correct I just wanted to keep the naming the same as the original scene naming so I just change it back to H264 here.

Code: Select all

{'-'+fn.replaceAll(/$n/,n.replaceAll(/ [-]/,'.')).match(/(?:(?<=[-])(?!(cd|CD)[0-9]+)\w+$)|(?:^(?!(cd|CD)[0-9]+)[A-Za-z0-9]+(?=[-]))|(?:(?<=^[\[])[^\]]+(?=[\]]))|(?:(?<=[\[])[^\]]+(?=[\]]$))/)}
This last one is a more complicated regex for matching group names. It matches groups in the format filename-group.ext, group-filename.ext, [group]filename.ext, filename[group].ext.

It includes a fix for false positives from shows/movies with titles that are hyphenated, e.g. "X-Men" would lead to: filename-X.ext.
It also no longer gives false positives for multi-part files in the format cd1-filename.ext or filename-cd1.ext.

I hope this helps. If you have any questions feel free to reply back here or even PM me.

Also let me know if you come up with anything new.
Igor
Posts: 14
Joined: 27 Jun 2012, 21:04

Re: Keeping tags like REPACK,PROPER...

Post by Igor »

Oh also if you are interested here is the naming scheme I use for movies. Basically the same as the other one but obviously no episode titles or whatever and it includes the movie year and matches things like "Director's Cut".

Code: Select all

{n.upperInitial().space('.').replaceAll(/[,()]+/).replaceAll(/\.-\./,'.')}{".$y"}{"."+fn.match(/(?i:unrated)/).toLowerCase().upperInitial()}{"."+fn.match(/(?i:uncut)/).toLowerCase().upperInitial()}{"."+fn.match(/(?i:Director.*Cut)/).toLowerCase().upperInitial()}{"."+fn.match(/(?i:extended)/).toLowerCase().upperInitial()}{"."+fn.match(/(?i:internal)/).toUpperCase()}{"."+fn.match(/(?i:repack)/).toUpperCase()}{"."+fn.match(/(?i:proper)/).toUpperCase()}{".Part.$pi"}{(dim[1]>480 && dim[0]==1280) ? '.720p' : (dim[1]>720 && dim[0]==1920) ? '.1080p' : null}{".$source"}{"."+ac.match(/DTS/)}{".$vc"}{'-'+fn.replaceAll(/$n/,n.replaceAll(/[-]/,'.')).match(/(?:(?<=[-])(?!(cd|CD)[0-9]+)\w+$)|(?:^(?!(cd|CD)[0-9]+)[A-Za-z0-9]+(?=[-]))|(?:(?<=^[\[])[^\]]+(?=[\]]))|(?:(?<=[\[])[^\]]+(?=[\]]$))/)}
User avatar
rednoah
The Source
Posts: 19139
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Keeping tags like REPACK,PROPER...

Post by rednoah »

With next version I'm gonna at function matchAll that'll make it easier to match many tags. Also making things case-insensitive by default.

e.g.

Code: Select all

{fn.matchAll(/repack|proper|extended/).join('.').lower().upperInitial()}
:idea: Please read the FAQ and How to Request Help.
Igor
Posts: 14
Joined: 27 Jun 2012, 21:04

Re: Keeping tags like REPACK,PROPER...

Post by Igor »

Nice. That will make things much cleaner.

Thanks rednoah.
seriezman
Posts: 5
Joined: 03 May 2012, 20:57

Re: Keeping tags like REPACK,PROPER...

Post by seriezman »

Thank you for the guide links.I couldn't understand Regex tutorials for now because my of my English.I'm having a English course this year for college.Hope to understand all of them soon...And Thank you so much for explaining the scheme.Nobody helps like that these days :)

I tried your formats and it gives results like this.
Name.S01E20.Episode.Title.HDTV.XviD-[fqm, null, null]

in the movie format editing screen it says something like "there isn't a variable called dim" as a result of that
the resolution(720p,1080p) is not added in the name.Also [Group, null, null] thing continues.

1.can we remove the nulls and [] signs
2.can we keep the originial group name capitalization. for example file comes with group aaf i want it to turn to aAF.
3.What can you do with the resolution problem?
4.Some series got ws tag.I got it done with the same way that i do "repack".but sometimes it gives false positives to files which have "ws" letters in any word.Is this problem solvable?
5.When writing schemes how do you know the signs that you use\(programmers say it syntax if I remember it right.)
6."http://filebot.sourceforge.net/naming.html" does this page contain all the functions that the program has?
7.I know I ask too much:)
User avatar
rednoah
The Source
Posts: 19139
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Keeping tags like REPACK,PROPER...

Post by rednoah »

1. That's all in the scripting. Filtering null values or using empty strings, etc. Depends on the expression but everything is possible.

2. Look into {group} binding. Note: FileBot needs to know all groups names in advance.

3. Update to the latest HEAD revision

4. Use word-boundary matcher \b in your regex. Or better yet, use {ws} which is based on the actual video aspect ratio.

5. Naming scheme expressions are Groovy code (with a small number of extra functions predefined)

6. That's just extra useful things that are predefined by filebot. You can use everything Groovy or the Java runtime have to offer.
:idea: Please read the FAQ and How to Request Help.
Igor
Posts: 14
Joined: 27 Jun 2012, 21:04

Re: Keeping tags like REPACK,PROPER...

Post by Igor »

seriezman wrote: I tried your formats and it gives results like this.
Name.S01E20.Episode.Title.HDTV.XviD-[fqm, null, null]

Not sure why you're getting that. What's the source file name?

I've never seen anything like that come up with this expression. The group shouldn't be surrounded by square brackets at all and I have no idea where the null's are coming from.

As for #2, rednoah is right, the only way to introduce the proper capitalization for the groups if it isn't there to begin with is by using the {group} binding. The downside of that is that if your group isn't on the list it won't be detected, but rednoah is pretty good at keeping the list updated as soon as you post missing groups.

3. Just as rednoah says, but I will add that you can find the latest revision here: http://sourceforge.net/projects/filebot ... ebot/HEAD/

4. If you just want the ws tag use the {ws} binding. If you want to tinker with it and maybe learn a bit more by doing it yourself you can do it the regex way, but I would just use the binding. Rednoah has already done the work for you.


Nothing else to add here, except for that your English seems fine and don't worry about asking too many questions. It's a young community at FileBot and questions help everybody.
seriezman
Posts: 5
Joined: 03 May 2012, 20:57

Re: Keeping tags like REPACK,PROPER...

Post by seriezman »

thanks for answers.
Latest Revision solved the problem.First I thought latest msi package contains the latest revision.Later I got the HEAD thing.
For WS tag /b worked.
for groups i found a site http://scenegrouplist.com/lists.php
there are sooo many of them . Maybe rednoah wants to see it.
Mortyfar
Posts: 12
Joined: 04 Jun 2018, 09:47

Re: Keeping tags like REPACK,PROPER...

Post by Mortyfar »

Hi,
I am hoping this it the right place to put this query, if not please excuse my ignorance.

I am new to using filebot, and have found most of what I need on the forums, but I have stumbled into this issue and I can't seem to find the solution.
I am trying to keep the script simple without doing a bunch of cleanup commands.
here is my current script:

Code: Select all

-script fn:amc --log-file d:/bittorrent/filebot/amc.log --output "d:/bittorrent/filebot" --action test --conflict skip -non-strict "d:/bittorrent/rename" --filter "readLines('D:/bittorrent/filebot/include.txt').join().findAll(/\d+[^(\d{4})]/)*.toInteger().contains(id)" --def movieFormat="e:/movies/{n.replace(':',' -')} ({y})/{n.replace(':',' -')} ({y})" seriesFormat="d:/series/{n}/{'Season '+s}/{n} - {s00e00} - {t} ({fn.match(/(?i)proper|repack/).lower().upperInitial()})"
It works very well and returns the filename with i.e. (Proper) at the end if proper is in the filename.
now, the problem is, if there is no instance of proper/repack, it will add () at the end of the filename.
I already tried ({"."+fn. ect. and that did not work.
I can not figure it out so I am hoping someone can help here with a simple solution.
User avatar
rednoah
The Source
Posts: 19139
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Keeping tags like REPACK,PROPER...

Post by rednoah »

Here's a solution for you:

Code: Select all

{ '(' + fn.match(/(?i)proper|repack/) + ')' }
:arrow: This thread explains why it works: viewtopic.php?f=5&t=1895


:idea: Please read Cmdline and Argument Passing.

:idea: Use the @file syntax for reading command-line arguments from external text files.


The last two :idea: might explain why you had trouble making it work before (i.e. " is interpreted by the shell, so you need to escape things correctly to actually literally pass " as argument value into FileBot).
:idea: Please read the FAQ and How to Request Help.
Mortyfar
Posts: 12
Joined: 04 Jun 2018, 09:47

Re: Keeping tags like REPACK,PROPER...

Post by Mortyfar »

thank you very much, that works.
yob
Posts: 3
Joined: 03 Jul 2018, 22:32

Re: Keeping tags like REPACK,PROPER...

Post by yob »

rednoah wrote: 09 Aug 2012, 10:56 With next version I'm gonna at function matchAll that'll make it easier to match many tags. Also making things case-insensitive by default.

e.g.

Code: Select all

{fn.matchAll(/repack|proper|extended/).join('.').lower().upperInitial()}
Shouldn't this also be possible with a foreach somehow?
Could use a foreach alot, didn't find a single way to do it though.

What I was thinking about, but doesn't work...

Code: Select all

{
  def list = ['internal','repack','uncut']
  for(item in list){
    fn.match(/(?i:item)/).toUpperCase() /* Option 1 */
    fn.match(/(?i:${item})/).toUpperCase() /* Option 2 */
  }
}
I'm struggeling with the right way to call the current item
Post Reply