Page 1 of 1

rename one subtitle if it has the same name as another one

Posted: 11 Oct 2018, 00:40
by Smallville131
Hi,
I'm sorry if I'm the 101st person to ask how to make filebot (GUI on windows 10) format the way it renames duplicate e.g
I have a lot subtitle and sometime 2 or 3 in one language. if I format them with this:

Code: Select all

/{ny}/{ny}{subt}{'.'+fn.match(/forced/)}
a subtitle like subtitlea.srt and subtitleb.srt are getting named the same (correct way) but than I would get a duplicate which means I can't move them (or at least one subtitle) to the new location.

I would like to have something like

subtitle.1.srt
subtitle.2.srt

or with language

subtitle.en-US.1.srt or subtitle.en-US1.srt,
as a result.

That leads me to a second point: My system requieres the language tag to be '2 letter'-all caps 2 Letter '
or just for english 'en-US': how can I do that with subt oder other functions?


Thank you for your help, I appreciate every tip and trick and please be patient with me, I'm new to all of this :D

Re: rename one subtitle if it has the same name as another one

Posted: 11 Oct 2018, 04:00
by rednoah
1.
Adding numbers is not supported in the GUI. If you're using the CLI, then the --conflict index option may or may not do the trick. This particular use-case has not been tested.

What are the original file paths of these subtitles? Full file paths for testing would be appreciated. Usually, the best way is to use fn.match() to keep some number or tag or whatever makes the original file path unique to make sure the destination paths of both subtitle files are different.


EDIT:

The duplicate index binding {di} may or may not work in this use case:

Code: Select all

{di}


2.
You can use the {lang} binding to get a Language object and then do with that whatever you want:

Code: Select all

{lang.ISO2}

Re: rename one subtitle if it has the same name as another one

Posted: 11 Oct 2018, 11:11
by Smallville131
Thanks for the input.

Code: Select all

{di}
gives all of the files an index so if 3 subs and a movie file should be renamed it goes from 1 to 4.
Maybe an if else which compares the names of the files and if identical one should be renamed?

With

Code: Select all

{'.'+lang.ISO2}{if(lang.ISO2=='en') '-US'}
I got my language the way I need- thank you :D

If I use fn.match like this

Code: Select all

{'.' + fn.match(/1/)} 
every file gets a 1 because they have sometimes 1080p in the name (same with 1 and 2 with 2160p)

My file path for the subtitles is the same as to the movie file:

Code: Select all

D:/new movies/{ny}/ 
and here all files (subs+movie): 
{ny}{'.'+lang.ISO2}{if(lang.ISO2=='en') '-US'}{if(fn=='eng')'.en-US'}{'.'+ fn.match(/forced/)}

Re: rename one subtitle if it has the same name as another one

Posted: 11 Oct 2018, 11:45
by rednoah
1.
Can you give an example file paths of multiple subtitle files that have unique source file paths but evaluate to the same destination path?


2.
You can use {lang.tag} for your particular use case, which will give you the BCP 47 language tag (e.g. en-US).

Re: rename one subtitle if it has the same name as another one

Posted: 11 Oct 2018, 12:39
by Smallville131
Lang.tag works perfectly, thank you.

right now I'm looking at
the interview.
the interview-eng.
the interview-b-eng.
the-interview-eng-b.

Another problem is, that if after the language letter comes anything else, filebot won't recognise the eng (last example) and I get 2 the Interview.srt files. And if I manage to let them be recognized correctly I think I get 3 The Interview.en-US. files.
One should be something like The Interview.en-US.b or 2 next with c/3 and so on

Re: rename one subtitle if it has the same name as another one

Posted: 11 Oct 2018, 13:13
by Smallville131
With if and else I have a solution for those particular files:

Code: Select all

{ny}{'.' + lang.tag}
{if(fn.match(/eng-b/)) '.en-US.b'}{if(fn.match(/eng-subs/)) '.en-US'}
{if(fn.match(/ger-b/)) '.de-DE.b'}{if(fn.match(/ger-subs/)) '.de-DE'}
{'.'+ fn.match(/forced/)}
but I would need to insert all exceptions manuelly for every language, which is kind of a bummer.
Furthermore I'm not sure how well the program works with many if and else- any recommandations performance wise?

Re: rename one subtitle if it has the same name as another one

Posted: 11 Oct 2018, 17:05
by rednoah
1.
Well, if the only difference here is that some files have dashes and other not, and that's why you have unique source file paths, then FileBot can't do much here:

Code: Select all

the interview.
the interview-eng.
the interview-b-eng.
the-interview-eng-b.
Code-wise, you'd go for the "-b" marker at the end of the file name, which is independent of the language code:

Code: Select all

{lang.tag}{'.'+fn.match(/-b\b/).match(/\w+/)}
\b ... word boundary
\w ... word character

:arrow: https://regexr.com/


2.
Thinking outside the box, you could just add something like {crc32} at the end for each subtitle file, which will guarantee that each subtitle file gets each own unique destination path.

Re: rename one subtitle if it has the same name as another one

Posted: 11 Oct 2018, 18:33
by Smallville131
yes with crc32 I get a unique filename ending. thumbs up :D Thank you very much for the fast answers

If you have still some time: in another example I get a new problem:
would be nice if I could use the fn.match for replace the specific part I'm forcing to be there (yes... makes totally sense) with something like .en-US :
I get:
subtitle-eng-subs.srt -> subtitle.srt

or with fn.match

subtitle-eng-subs.srt-> subtitle.subs.srt

result should be subtitle.en-US.srt

Re: rename one subtitle if it has the same name as another one

Posted: 12 Oct 2018, 02:51
by rednoah
Does {lang} not work? {lang} lang will use statistical language detection based on the subtitle file content, so you'll get the right language tag even if the file name doesn't have any.

Re: rename one subtitle if it has the same name as another one

Posted: 12 Apr 2020, 04:13
by AbedlaPaille
Am too computer incompetent to understand the discussion here. To sum up is there a way to rename multiple English subtitles (1), (2), (3) like Windows does instead of overwriting the previous .eng? If yes i could use a more step by step tutorial. Glad i finally bought it from the Windows store though, your involvement in the forum and reddit to help users is what made me go through with it.

Re: rename one subtitle if it has the same name as another one

Posted: 12 Apr 2020, 05:37
by rednoah
Have you tried something like this yet?
rednoah wrote: 03 Jan 2020, 19:34 The {di} duplicate index and {dc} duplicate count should do the job:

Code: Select all

{if (dc > 1) ".part$di"}
Image

Re: rename one subtitle if it has the same name as another one

Posted: 12 Apr 2020, 12:10
by AbedlaPaille
Didn't manage to make it work but this does the job for me:

Code: Select all

{'.'+pi}{'.'+lang}
So now my problem is separating the 2 pi instructions. My {'.'+pi} on subtitle files and the normal {'.CD'+pi} on video files, got any ideas? Cheers on the support!

Re: rename one subtitle if it has the same name as another one

Posted: 07 May 2020, 14:45
by AbedlaPaille
rednoah wrote: 12 Apr 2020, 05:37 Have you tried something like this yet?
rednoah wrote: 03 Jan 2020, 19:34 The {di} duplicate index and {dc} duplicate count should do the job:

Code: Select all

{if (dc > 1) ".part$di"}
Image

Code: Select all

{if (dc > 1) " ($di)"}
This has been a time savior, thank you so much. But why doesn't it take into consideration the {lang} binding? Avatar.en (1) and Avatar.fr (2) are seen as duplicates when ideally the $di would only display if same sub language, eg Avatar.en ; Avatar.fr (1) ; Avatar.fr (2)

And it would be bloody fantastic if i could start showing the $di at 2 instead of 1, eg Avatar.en ; Avatar.fr ; Avatar.fr (2)

Re: rename one subtitle if it has the same name as another one

Posted: 07 May 2020, 15:45
by rednoah
The {di} and {dc} bindings are generic, and not necessarily designed and optimized for your particular use case.


:idea: You could write your own code based on {model} and count and detect duplicates with your own logic according to your needs, though it won't be easy:
viewtopic.php?t=9814