How to add number after subtitles conflicts?

All about user-defined episode / movie / file name format expressions
Post Reply
easonksh
Posts: 5
Joined: 14 Feb 2017, 14:31

How to add number after subtitles conflicts?

Post by easonksh »

I have multiple subtitles files in the same language, which I often get conflicting error renaming.

Example:
Love and Death.chi.srt
Love and Death.chi1.srt

When I use

Code: Select all

{subt}
It would just give me back two exact same "Love and Death.chi.srt" with conflicting error.

What should I do to just add a number after one of the "Love and Death.chi.srt"?

Thanks!
User avatar
rednoah
The Source
Posts: 22980
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to add number after subtitles conflicts?

Post by rednoah »

Why do you have two Chinese subtitles? What makes them different? Hearing Impaired? Charset?

You'll have to somehow come up with unique file paths in your format (e.g. by proping the subtitle content, keeping parts of the original filename, etc).
:idea: Please read the FAQ and How to Request Help.
easonksh
Posts: 5
Joined: 14 Feb 2017, 14:31

Re: How to add number after subtitles conflicts?

Post by easonksh »

rednoah wrote:Why do you have two Chinese subtitles? What makes them different? Hearing Impaired? Charset?

You'll have to somehow come up with unique file paths in your format (e.g. by proping the subtitle content, keeping parts of the original filename, etc).
Some of them are Traditional Chinese and some of them are Simplified Chinese, and I am not sure if all the sub files are synced correctly so I just gave them chi1/chi2/chi3...
User avatar
rednoah
The Source
Posts: 22980
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to add number after subtitles conflicts?

Post by rednoah »

{subt} won't work naming standards you've come up with yourself.

You can grab that bit from the filename though:

Code: Select all

fn.match(/\.chi\d*/)
:idea: Please read the FAQ and How to Request Help.
easonksh
Posts: 5
Joined: 14 Feb 2017, 14:31

Re: How to add number after subtitles conflicts?

Post by easonksh »

Can I actually match only .chi1/.eng/.chi&eng into all new .srt filenames (extracting srt descriptions)?

Using this

Code: Select all

fn.match(/\.chi\d*/)
instead of

Code: Select all

{subt}
will ignore all other languages sub files.

Thanks for the help, filebot newbie asking so much.
User avatar
rednoah
The Source
Posts: 22980
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to add number after subtitles conflicts?

Post by rednoah »

You could grab the last .whatever bit. That'll work for any language suffix.

e.g.

Code: Select all

'name.chi1'.match(/\.\w+$/)
:idea: Please read the FAQ and How to Request Help.
easonksh
Posts: 5
Joined: 14 Feb 2017, 14:31

Re: How to add number after subtitles conflicts?

Post by easonksh »

Code: Select all

{home}/Steven Spielberg/{y} - {n.replaceAll(/[`´‘'*’?":ʻ,]/, "")}/{n.upperInitial().space('.').replaceAll(/[`´‘*'’?":ʻ,]/, "")}.{y}{'.'+source}.{vf}.{vc}{'.'+group}{'name.chi'.match(/\.\w+$/)}
It now gives me .chi on every files.
Image
easonksh
Posts: 5
Joined: 14 Feb 2017, 14:31

Re: How to add number after subtitles conflicts?

Post by easonksh »

After a bit of stupid trying

Code: Select all

{'.'+fn.match(/chn&eng|cht&eng|chn&eng|chs&eng|eng&chn|eng&chi|eng&chs|eng&cht|chi1|chi2|chi|chn1|chn2|chn3|chn|chs|chs1|cht1|cht2|cht|eng|eng1|eng2|eng/)}
it does give me the results I want but it will match the sub description with the filename itself
which will add an unnecessary .Chs in some of the files like:

-Matchstick.Men.2003.HDTV.mp4
-Matchstick.Men.2003.HDTV.chi.srt
-Matchstick.Men.2003.HDTV.eng&chi.srt

it will give me:

-Matchstick.Men.2003.HDTV.Chs.mp4
-Matchstick.Men.2003.HDTV.Chs.srt
-Matchstick.Men.2003.HDTV.Chs.srt
User avatar
rednoah
The Source
Posts: 22980
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to add number after subtitles conflicts?

Post by rednoah »

You're matching the chs in Matchstick:
http://regexr.com/3f9vs

I use \. (literal dot) and $ (ending of string) for a reason. ;)


e.g. for testing:

Code: Select all

'Name.HDTV.chi&eng'.match(/\.[a-z&]+$/)
e.g. for your format, using the fn binding and only if the file extension is srt:

Code: Select all

if (ext == 'srt') fn.match(/\.[a-z&]+$/)
This snippet assumes that all your *.srt files end with a .lang suffix.
:idea: Please read the FAQ and How to Request Help.
Post Reply