Change : to -

All your suggestions, requests and ideas for future development
Post Reply
cortx
Posts: 3
Joined: 17 Aug 2019, 15:24

Change : to -

Post by cortx »

Hello;

Since I use Filebot (many years ago now) I think something should be changed and I write it only now.
When we rename files from Movie DB, some name are labelled with [:] (ie https://i.imgur.com/SAbXSRp.png )
But on windows, a name with [:] is not a valid name so Filebot ask to remove those [:] ( https://i.imgur.com/0vD8Mvx.png )
The problem is I should rename them after Filebot run and add a [-] instead of the double [space] that Filebot created when he had deleted the [:]

Is it possible to patch Filebot to not remove [:] but write [-] instead ?

Regards
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Change : to -

Post by rednoah »

:idea: File naming is completely up to your custom format, including any character replacements you may wish.


The {plex} binding will do that implicitly:

Code: Select all

{plex}
:arrow: viewtopic.php?t=4116


If you have your own custom format, then I recommend using the String.colon​(String replacement) convenience method:

Code: Select all

{n.colon(' - ')}
:idea: Please read the FAQ and How to Request Help.
cortx
Posts: 3
Joined: 17 Aug 2019, 15:24

Re: Change : to -

Post by cortx »

The format that I use is simple: {n} ({y})
Will try {n.colon(' - ')} ({y}) tomorrow.
Thank you.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Change : to -

Post by rednoah »

I recommend using the {plex} format, since that'll implicitly take care of all of all the corner cases, not just the colon : replacement.

e.g. absolute plex path:

Code: Select all

X:/Media/{plex}
e.g. plex file name:

Code: Select all

{plex.name}
:idea: Please read the FAQ and How to Request Help.
cortx
Posts: 3
Joined: 17 Aug 2019, 15:24

Re: Change : to -

Post by cortx »

Tahnk you.
That work like a charm.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Change : to -

Post by Wolfie »

cortx, here's the format I use for my movies...

Code: Select all

{
   def vol="P", drive="01", drives="01|02|03|04|05|35|43|44"
   def releaseType='', replaceFinds="CGI", collectionsFolder="_", collectionsFile="P:/collections.txt", alt="wolf"
   def year=y, name=n.removeAll(/\s*\(\d{4}\)$/).colon(' - ').validateFileName(), group=any{group}{any{original}{fn}.match(/(?:-)([a-z\d]{1,15})$/)}{}
   def sub=any{"${collectionsFolder}/${any{readLines(collectionsFile).find{it=~imdbid}.after(':').before(/[:#\t*]/)}{collection}.replaceAll(/(\s(${replaceFinds})\s)/,' ').colon(" - ").validateFileName()}"}{}
   def root="${vol}:\\_${any{file.path.match(/(?<=^${vol}:?(\\dev)?\\_)(${drives})(?=\\)/)}{drive}}${any{file.path.match(/(\/${alt}\//)}{'/'}}"
   def releaseInfo(text) { return text.removeAll(/(${text.stripReleaseInfo().replaceAll(/ /,'.+')})[.)]*/).removeAll(/(^|\.)\[?[\da-f]{8}\]?/) }
   def release=allOf{allOf{source.upper()}{vf}{hd}{vc.match(/(hevc|[xh]\.?26\d)/).replaceAll(/[xh]\.?265/,'HEVC')}{bitdepth+"bit"}{ac}.join('.')}{group}.join('-')
   def releases=[file:releaseInfo(fn), original:any{releaseInfo(original)}{}]
   def part=any{fn.lower().find(/(?<=[. ](part|cd)[. ]?)\d+(?=[. ]|$)/)}{original.lower().find(/(?<=[. ](part|cd)[. ]?)\d+(?=[. ]|$)/)}
   def path=[
         movie:  "MOVIES",
         sub:    any{sub}{az}{n.match(/^(?:the|a )?.*?([\da-z])/).replaceAll(/\d/,"0-9")},
         folder: (sub?"${year} - ${name}":"${name} (${year})"),
         file:   allOf{allOf{"${name} (${year})"}{any{releases[releaseType]}{release}}{"(CD".concat(part)+")"}{"[${crc32}]"}{"CD".concat(part)}.join('.')}{subt}.join()
      ]

   return allOf{root}{path.values().join('/')}.join('/')
}
I'll explain some of it:
I use "P:" drive as my Plex drive, and have Junction points to folders on other drives linked in the root of "P:"
A couple of examples of root movie folders are "P:\_01\Movies" and "P:\_02\Movies." The folders "_01" and "_02" are the junction points I was talking about, and they lead to a folder named "MEDIA" on the root of other drives. The list of two digit numbers you see "01|02|03|etc" are valid junctions that can be used.

The part that should be of particular interest to you is this:

Code: Select all

name=n.removeAll(/\s*\(\d{4}\)$/).colon(' - ').validateFileName()
rednoah told me about that little gem a couple of years back. '.validateFileName()' will take the filename and make sure it's valid by stripping (or replacing?) any illegal character for the file system in use. As you can see, I'm also using the '.colon()' option to change colons to something more appropriate, but even without it, it wouldn't cause an issue.

If you decide to give the above code a try, then if you have a static root path that you pass along to filebot when calling on it, be sure to change the last line to this:

Code: Select all

   return {path.values().join('/')}
If you don't, then it will include a drive letter as part of the structure, causing issues. Either supply it via parameter to filebot, or via format, but not both.
Bexorcist
Posts: 28
Joined: 20 Dec 2020, 14:48

Re: Change : to -

Post by Bexorcist »

rednoah wrote: 18 Aug 2019, 05:38 I recommend using the {plex} format, since that'll implicitly take care of all of all the corner cases, not just the colon : replacement.

e.g. absolute plex path:

Code: Select all

X:/Media/{plex}
e.g. plex file name:

Code: Select all

{plex.name}
Hey Rednoah,

I'm just starting to know the system behind the Filebot renaming but when I use the {plex.name} code, my subtitles get the .eng addition to their name which causes it to not work in VLC anymore.
For example, now I'm using this string:

Code: Select all

{plex.name} [{genre}, {director}, {vf}]/{plex.name} [{genre}, {director}, {vf}]
This gives me the following result for the SRT file of a movie:

Code: Select all

Bad Boys (1995).eng [Action, Michael Bay, 1080p]/Bad Boys (1995).eng [Action, Michael Bay, 1080p]
Is there a way to get rid of the '.eng' part or to get it to show in the end so it will work with VLC?


Thx in advance!
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Change : to -

Post by Wolfie »

Bexorcist wrote: 20 Dec 2020, 17:01

Code: Select all

{plex.name} [{genre}, {director}, {vf}]/{plex.name} [{genre}, {director}, {vf}]
This gives me the following result for the SRT file of a movie:

Code: Select all

Bad Boys (1995).eng [Action, Michael Bay, 1080p]/Bad Boys (1995).eng [Action, Michael Bay, 1080p]
Is there a way to get rid of the '.eng' part or to get it to show in the end so it will work with VLC?
Try this:

Code: Select all

{ny} [{genre}, {director}, {vf}]/{plex.name} [{genre}, {director}, {vf}][subt]
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Change : to -

Post by rednoah »

{plex} will include the language suffix, so you can't use {plex} if you don't want the language suffix.


:arrow: Not using {lang} or {subt} in your custom format will do the trick:

Code: Select all

Movies/{ny}/{ny}
:idea: Please read the FAQ and How to Request Help.
Bexorcist
Posts: 28
Joined: 20 Dec 2020, 14:48

Re: Change : to -

Post by Bexorcist »

[/quote]
Try this:

Code: Select all

{ny} [{genre}, {director}, {vf}]/{plex.name} [{genre}, {director}, {vf}][subt]
[/quote]

This gives me the following result:

Code: Select all

Bad Boys (1995) [Action, Michael Bay, 1080p]/Bad Boys (1995).eng [Action, Michael Bay, 1080p][subt]
Not really what I'm after. :D
Main reason I want to use the Plex.name is to get the colon (:) replaced.
rednoah wrote: 21 Dec 2020, 02:34 {plex} will include the language suffix, so you can't use {plex} if you don't want the language suffix.


:arrow: Not using {lang} or {subt} in your custom format will do the trick:

Code: Select all

Movies/{ny}/{ny}
Yeah, but that would not get rid of the colon (:) issues, would it? Main reason I want to use the Plex.name is to get the colon (:) replaced. If I could get the .eng at the end it would work though.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Change : to -

Post by rednoah »

Bexorcist wrote: 21 Dec 2020, 08:18 Main reason I want to use the Plex.name is to get the colon (:) replaced.
e.g. DIY

Code: Select all

ny.colon(/ - /)
:idea: Please read the FAQ and How to Request Help.
Bexorcist
Posts: 28
Joined: 20 Dec 2020, 14:48

Re: Change : to -

Post by Bexorcist »

rednoah wrote: 21 Dec 2020, 08:58
Bexorcist wrote: 21 Dec 2020, 08:18 Main reason I want to use the Plex.name is to get the colon (:) replaced.
e.g. DIY

Code: Select all

ny.colon(/ - /)
OK, Thx a lot. Isn't there a way to use {plex.name} and get the language indicator as the extension? I managed to do so with the series renaming.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Change : to -

Post by rednoah »

Bexorcist wrote: 21 Dec 2020, 12:57 Isn't there a way to use {plex.name} and get the language indicator as the extension?
{plex} will indeed add the language indicator by default to the end of the file path, so what you're asking for seems to be the default behaviour.
:idea: Please read the FAQ and How to Request Help.
Bexorcist
Posts: 28
Joined: 20 Dec 2020, 14:48

Re: Change : to -

Post by Bexorcist »

rednoah wrote: 21 Dec 2020, 13:31
Bexorcist wrote: 21 Dec 2020, 12:57 Isn't there a way to use {plex.name} and get the language indicator as the extension?
{plex} will indeed add the language indicator by default to the end of the file path, so what you're asking for seems to be the default behaviour.
Well, with subs the .eng is placed in the middles (see example). Problem is with my formula the parent folder is changed with the language indication as well.

I'm still having a problem though. When renaming movies/series on other HDD's my renamed files/folders are moved every time. Isn't there a way to command the software to just rename the parent folder instead of moving it or creating it somewhere else?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Change : to -

Post by rednoah »

1.
Bexorcist wrote: 21 Dec 2020, 14:04 Well, with subs the .eng is placed in the middles (see example)
If you follow the {plex} format examples, then this will work out-of-the-box:

Code: Select all

{plex.derive{" by $director"}{" [$vf, $vc, $ac]"}.name}
:idea: plex.derive() can be used to insert additional information after the file name but before the subtitle language suffix and file extension.



2.
Bexorcist wrote: 21 Dec 2020, 14:04 Problem is with my formula the parent folder is changed with the language indication as well.
However, the {plex} format is indeed ill-suited if you need to customize every single level of the file path. If you want custom folder naming, then custom code is the easiest way to do it.

e.g.

Code: Select all

X:/Movies/
{ny.colon(/ - /)} {allOf{genre}{director}{vf}}
/
{ny.colon(/ - /)} {allOf{genre}{director}{vf}}
{subt}


3.
Bexorcist wrote: 21 Dec 2020, 14:04 I'm still having a problem though. When renaming movies/series on other HDD's my renamed files/folders are moved every time. Isn't there a way to command the software to just rename the parent folder instead of moving it or creating it somewhere else?
That's not possible for various reasons discussed at length in other threads. The gist is to organize files into a new pristine folder structure.
:idea: Please read the FAQ and How to Request Help.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Change : to -

Post by Wolfie »

Bexorcist wrote: 21 Dec 2020, 08:18
Try this:

Code: Select all

{ny} [{genre}, {director}, {vf}]/{plex.name} [{genre}, {director}, {vf}][subt]
This gives me the following result:

Code: Select all

Bad Boys (1995) [Action, Michael Bay, 1080p]/Bad Boys (1995).eng [Action, Michael Bay, 1080p][subt]
My fault, I used [ ] instead of { }.

Code: Select all

{ny} [{genre}, {director}, {vf}]/{plex.name} [{genre}, {director}, {vf}]{subt}
That should do it.

Though to be honest, if you're using Plex (you should if you aren't), it's unnecessary to do all that. For the most part, my movies are named with the name of the movie, the year, a few technical specs, and the CRC32 hash (used not only to test integrity, but also prevent naming conflicts).

Code: Select all

Example format: Bad Boys (1995).BLURAY.2160p.UHD.HDR10.HEVC.10bit.AAC-Tigole.[6C78E0B7].mkv
Still unnecessary when you think about it, but does tell me what I need to know about the file itself in case I need to move or delete one, instead of wondering which is which.
Post Reply