Page 1 of 1

Can't rename subtitle properly

Posted: 30 Mar 2016, 12:48
by raxer
Hi,

i have problems to rename the subtitle properly :(

the input files have almost always the same file name scheme:

Code: Select all

group-movie-1080p.mkv
group-movie-1080p-eng.idx
group-movie-1080p-eng.sub
group-movie-1080p-forced.idx
group-movie-1080p-forced.sub
group-movie-1080p.idx
group-movie-1080p.sub
Now i want them in this format:

Code: Select all

Movie (2016)/Movie (2016) - 1080p.mkv
Movie (2016)/Movie (2016) - 1080p.eng.idx
Movie (2016)/Movie (2016) - 1080p.eng.sub
Movie (2016)/Movie (2016) - 1080p.ger.forced.idx
Movie (2016)/Movie (2016) - 1080p.ger.forced.sub
Movie (2016)/Movie (2016) - 1080p.ger.idx
Movie (2016)/Movie (2016) - 1080p.ger.sub
but i am not able to create nested if clauses. also i don't know how to tell filebot that the main video file has the resolution 1080p which should also appear in the subtitle name.

with my naming scheme:

Code: Select all

/movies/{n.upperInitial().space(' ')} ({y})/{n.upperInitial().space(' ')} ({y}) - {vf}{mediaType[0].match(/subtitle/) ? fn.match(/[-_]+eng/) ? fn.match(/[-_]+forced/) ? '.eng.forced' : '.eng' : fn.match(/[-_]+forced/) ? '.ger.forced' : '.ger' : ''}
i always get:

Code: Select all

Movie (2016)/Movie (2016) - 1080p.mkv
Movie (2016)/Movie (2016) - .idx
Movie (2016)/Movie (2016) - .sub
Movie (2016)/Movie (2016) - .idx
Movie (2016)/Movie (2016) - .sub
Movie (2016)/Movie (2016) - .idx
Movie (2016)/Movie (2016) - .sub

Re: Can't rename subtitle properly

Posted: 30 Mar 2016, 16:13
by rednoah
Here's the solution:

Code: Select all

{ny} - {vf} {fn =~ /[.]eng$/ ? '.eng' : '.ger' }{'.'+fn.match(/forced/)}
:idea: If you use my code, then you must also make a donation.

Re: Can't rename subtitle properly

Posted: 01 Apr 2016, 12:58
by traxxus
rednoah wrote:Here's the solution:

Code: Select all

{ny} - {vf} {fn =~ /[.]eng$/ ? '.eng' : '.ger' }{'.'+fn.match(/forced/)}
:idea: If you use my code, then you must also make a donation.
If i use this, the MKV file has also .ger or .eng - how to avoid this?

Re: Can't rename subtitle properly

Posted: 01 Apr 2016, 13:07
by rednoah
Example:

Code: Select all

{if (file.subtitle) fn =~ /[.]eng$/ ? '.eng' : '.ger' }
The the latest revision / RC build you can just do {subt} for all the subtitle language/category tags, though language detection might not be as accurate as just forcing between eng/ger manually.

Re: Can't rename subtitle properly

Posted: 08 Apr 2016, 12:33
by traxxus
Will / is this feature {subt} be implemented in the AMC script?

Re: Can't rename subtitle properly

Posted: 09 Apr 2016, 14:08
by raxer
Thanks for the help.

Is it possible to get the resolution of a video file in the same folder as the subtitle?

For example i want "1080p" in the subtitle file.

I would do the following procedure:
- List all files in the same folder like the subtitle
- Find the first movie file in the folder
- get the resolution
- Paste it to the subtitle file

Is this possible as format expression?

Re: Can't rename subtitle properly

Posted: 09 Apr 2016, 15:00
by rednoah
If the subtitle filename matches the movie filename, then this behaviour is default, i.e. all mediainfo/file bindings will work based on the movie file when formatting the corresponding subtitle file.

Re: Can't rename subtitle properly

Posted: 09 Apr 2016, 18:14
by raxer
I've tested it and it works. Thanks a lot!

Re: Can't rename subtitle properly

Posted: 19 Jun 2016, 08:41
by s25a
Hi,

I have the same question / issue like the author of this thread. As I do not understand all the scripting can someone help and post the final and complete code for the correct renaming?
If I use the code

Code: Select all

{ny} - {vf} {fn =~ /[.]eng$/ ? '.eng' : '.ger' }{'.'+fn.match(/forced/)}
the Videofile is llso renamed with .ger as mentioned above.

and I am not sure where to put this correctly

Code: Select all

{if (file.subtitle) fn =~ /[.]eng$/ ? '.eng' : '.ger' }
Thanks

S

Re: Can't rename subtitle properly

Posted: 19 Jun 2016, 08:47
by rednoah
1.
Have you tried using the subt binding?

Code: Select all

{subt}
2.
Where to put this? Just take a few example files, put it anywhere in your format, and see what happens:

Code: Select all

{if (file.subtitle) fn =~ /[.]eng$/ ? '.eng' : '.ger'}
Just play with it. You'll figure it out.

Re: Can't rename subtitle properly

Posted: 19 Jun 2016, 08:50
by s25a
Hi,

thank you so much for the quick answer :-)

To be honest - I have absolutely no idea what this all do so if you wnat me to play with that I even do not know where to start. :?
Have you tried using the subt binding?
What exactly do you mean by that?

Appreciate your support

S

Re: Can't rename subtitle properly

Posted: 19 Jun 2016, 09:13
by rednoah
Open the format editor and start "coding" and see what happens. There's plenty of examples you can look at. First you copy something that works, then you slightly modify it and see if it still works. That's how you figure it out. ;)

* http://www.filebot.net/naming.html
* http://www.filebot.net/forums/viewtopic.php?f=5&t=2#p51

There's some help on custom formats in this video tutorial around the 8 minute mark:
https://www.youtube.com/watch?v=zcSFKiwFLZw

Image