Regex for lowercase, crop and replace
Regex for lowercase, crop and replace
Hello, which regex-magic is necessary to change the filenames like these?
name s00e00 title.year-source.ac-af.mbps-vc.fps-vf.extension
Breaking Bad s03e05 Offene Worte.2010-bluray.dts-6ch.4.9-avc.29-720p.mkv
Children of Men.2011-dvd.ac3-2ch.0.8-xvid.25-394p.m4v
The challenge:
- all lowercase of type information
- shortened framerate, e.g. 29 instead 29.976 and 30 instead 30.000.
- rounded (or shortened if not possible) bitrate in mbps with 1 decimal-place, e.g. "4.9" instead "4 890 Kbps" and "0.8" instead "830 Kbps".
- the file name extension .mp4 to .m4v and lowercase.
- source "DVDrip" to "dvd" and "BluRay" to „bluray"
- if no information like source or year exists the output has to be adjusted
name s00e00 title.year-source.ac-af.mbps-vc.fps-vf.extension
Breaking Bad s03e05 Offene Worte.2010-bluray.dts-6ch.4.9-avc.29-720p.mkv
Children of Men.2011-dvd.ac3-2ch.0.8-xvid.25-394p.m4v
The challenge:
- all lowercase of type information
- shortened framerate, e.g. 29 instead 29.976 and 30 instead 30.000.
- rounded (or shortened if not possible) bitrate in mbps with 1 decimal-place, e.g. "4.9" instead "4 890 Kbps" and "0.8" instead "830 Kbps".
- the file name extension .mp4 to .m4v and lowercase.
- source "DVDrip" to "dvd" and "BluRay" to „bluray"
- if no information like source or year exists the output has to be adjusted
Re: Regex for lowercase, crop and replace
Have you looked at the format expressions? Like the examples here in the forums? You can play with it in the GUI editor.
By default filebot won't allow u to change the extension, but if you change to "Extension: Override" in Rename Options you can enable that. Just make sure you include the extension in your format.
By default filebot won't allow u to change the extension, but if you change to "Extension: Override" in Rename Options you can enable that. Just make sure you include the extension in your format.
Re: Regex for lowercase, crop and replace
It's all pretty straight-forward. Here's some hints:
Code: Select all
{vc.lower()} {ac.lower()}
Code: Select all
{video.FrameRate.toFloat().round()}
Code: Select all
{(video.bitrate.toFloat() / 1024).round(1)}
Code: Select all
{ext.equalsIgnoreCase('m4v') ? 'mp4' : ext.lower()}
Code: Select all
{source.lower().replaceAll(/dvdrip/, 'dvd')}
Re: Regex for lowercase, crop and replace
Thanks. Where is a complete documentation / reference? .round isn't mentioned here:
http://www.filebot.net/naming.html
http://www.filebot.net/forums/viewtopic.php?f=5&t=2#p51
I need a function to short the framerate 29.976 without rounding to 29. How to obtain with regex?
How to adjust the output when no source is given? At the moment it looks like this:
Avatar.2009-.dts-6ch.5503-x264.23.98-720p.mkv
{n}.{y}-{source.lower()}.{ac.lower()}-{af.lower()}.{(video.bitrate.toFloat()/1000).round()}-{vc.lower()}.{video.framerate.toFloat().round(2)}-{vf}
http://www.filebot.net/naming.html
http://www.filebot.net/forums/viewtopic.php?f=5&t=2#p51
I need a function to short the framerate 29.976 without rounding to 29. How to obtain with regex?
How to adjust the output when no source is given? At the moment it looks like this:
Avatar.2009-.dts-6ch.5503-x264.23.98-720p.mkv
{n}.{y}-{source.lower()}.{ac.lower()}-{af.lower()}.{(video.bitrate.toFloat()/1000).round()}-{vc.lower()}.{video.framerate.toFloat().round(2)}-{vf}
Re: Regex for lowercase, crop and replace
1.
Complete documentation on the Groovy programming language:
http://groovy.codehaus.org/Documentation
2.
So you don't want to round, just typecast to int:
3.
Every {...} block works as a whole or fails as a whole.
Look at the examples more closely => http://www.filebot.net/forums/viewtopic ... 5&t=2#p783
Complete documentation on the Groovy programming language:
http://groovy.codehaus.org/Documentation
2.
So you don't want to round, just typecast to int:
Code: Select all
(int) video.FrameRate.toFloat()
Every {...} block works as a whole or fails as a whole.
Look at the examples more closely => http://www.filebot.net/forums/viewtopic ... 5&t=2#p783
Re: Regex for lowercase, crop and replace
Thanks. Now I've got it.
Movie Format: Children of Men.2009.bluray.6ch.dts.23fps.5503kbps.x264.720p.mkv
Episode Format: Breaking Bad S03E11 Offene Worte.2002.ithd.2ch.ac3.25fps.4361kbps.avc.720p.mkv
Movie Format: Children of Men.2009.bluray.6ch.dts.23fps.5503kbps.x264.720p.mkv
Code: Select all
{n}.{y}.{source.lower()}.{af.lower()}.{ac.lower()}.{(int)video.framerate.toFloat()}fps.{(video.bitrate.toFloat()/1000).round()}kbps.{vc.lower()}.{vf}
Episode Format: Breaking Bad S03E11 Offene Worte.2002.ithd.2ch.ac3.25fps.4361kbps.avc.720p.mkv
Code: Select all
{n} {s00e00} {t}.{y}.{source.lower()}.{af.lower()}.{ac.lower()}.{(int)video.framerate.toFloat()}fps.{(video.bitrate.toFloat()/1000).round()}kbps.{vc.lower()}.{vf}
More than one language
Is it possible to add all the audio languages to the filename? "audio.language" only inserts „de“ for german, but there is the original audio stream in english also in the .mkv-file. I’ve looked at the groovy documentation even before you posted the link, but where can I find in this programming language documentation a list of all keywords used by FileBot for fields? http://groovy.codehaus.org/Getting+Started+Guide
I’ve tried audio.stream1.language and audio[1].language and similar things to access the second audio stream. But no luck. MediaInfo shows a field „Audio_Language_Strings“ but how can it be accessed?
I’ve tried audio.stream1.language and audio[1].language and similar things to access the second audio stream. But no luck. MediaInfo shows a field „Audio_Language_Strings“ but how can it be accessed?
Re: Regex for lowercase, crop and replace
Use {media} or {audios} bindings:
Code: Select all
{media.Audio_Language_Strings}
Code: Select all
{audios.language}