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 » 17 Aug 2019, 15:31

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: 16936
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Change : to -

Post by rednoah » 17 Aug 2019, 16:21

: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 » 18 Aug 2019, 02:50

The format that I use is simple: {n} ({y})
Will try {n.colon(' - ')} ({y}) tomorrow.
Thank you.

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

Re: Change : to -

Post by rednoah » 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}
: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 » 19 Aug 2019, 15:46

Tahnk you.
That work like a charm.

User avatar
Wolfie
Posts: 102
Joined: 27 Oct 2015, 02:59

Re: Change : to -

Post by Wolfie » 29 Aug 2019, 12:19

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.

Post Reply