Formatting for private and plex use

All about user-defined episode / movie / file name format expressions
Post Reply
ye62dzec
Posts: 10
Joined: 09 Jan 2025, 16:24

Formatting for private and plex use

Post by ye62dzec »

Hey guys,

I'd like to get your input to some question I'm having. I have approx. 500 movies and several shows which I would like to restructure using FileBot.

General Structure

I have my folder

Code: Select all

N:\Filme # with all movies, some examples:
N:\Filme\10 Cloverfield Lane (2016)\10 Cloverfield Lane (2016).mkv
N:\Filme\300 (2006 - 2014)\300 (2006).mkv # part of the 300 collection
This structure works nice and well for plex, but I'd like to change it up a little.

First, I want a structure that suits me for my direct access.

I'm quite happy with the following format:

Code: Select all

{collection}/{plex.name} - {audioLanguages} {allOf{vf}{vc}{hdr.replace("Dolby Vision":"DV")}.joining(' ', ' [', ']')}/{plex.name} - {audioLanguages} {allOf{vf}{vc}{hdr.replace("Dolby Vision":"DV")}.joining(' ', ' [', ']')}
Image

What I dont like about it yet:
  • Collections with a single Movie are being created (blue). Is there any way to prevent this behavior?
  • Movies without a collection are being moved out of my N:\Filme folder to the root of N:\ (red). Any idea how to fix this without hard-coding the correct path?
  • I'd like to change the audio languages "deu" to "DE" and "eng" to "EN". I wasn't able to achive this using .replace nor .replaceAll (purple).
  • Finally, I'd like to know how to use the german name for renaming, when the only audioLanguage is german (green).
  • Other than that, do you have any insights on my naming system or hints, what I might want to include/exclude?
Assuming, all above mentioned problems are fixed, I'd like to think about my plex structure.

Structure for Plex

Using your Plex-FAQ, I want to create a hardlink for plex at (for example)

Code: Select all

# plex folder
N:\Filme_Plex 
and continue to store my files in

Code: Select all

# media folder
N:\Filme 
Is there a way to automatically create the appropriate hardlinks in the plex folder when renaming in the media folder?

My current workaround is using two presets:
  1. Preset: rename movies in media folder.
  2. Select renamed movies in step 1 and paste them to filebot again.
  3. Preset: create hardlink in plex folder.
Is there a nicer way to deal this with?

Looking forward to your help.
Loving this tool - I actually enjoy playing around with this tool :D
User avatar
rednoah
The Source
Posts: 23743
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Formatting for private and plex use

Post by rednoah »

1.
The {model} binding can be used to move / rename files different depending on the other files being moved / renamed along side, i.e. move movies into a collection folder only if you actually have 2 or more movies of that collection loaded into FileBot. (NOTE: This is a topic for a dedicated thread if you need code-level support.)



2.
You'll want your format to start with N:\Filme to define exactly what you want. If your format is relative, then FileBot will resolve the target file path relatively to the current file path, which may or may not always be what you want it to be depending on the file path at hand.

e.g.

Format: Select all

N:/Plex/{ plex.id }


3.
{audioLanguages} will give you a list of Language objects which contain all the language names and codes:

Format: Select all

{ audioLanguages.ISO2.joining(', ', '[', ']').upper() }

Code: Select all

[EN, JA]


4.
The {localize} dynamic localization binding can be used to access the German movie name at format time - depending on the file at hand - even if you're matching in English. (NOTE: This is a topic for a dedicated thread if you need code-level support.)



5.
I strongly recommend separating your custom structure that has files named and organised to your preferences, and a secondary structure for Plex were files are named and organised for Plex. Looks like you're already on the right path there. A auto-generated secondary structure using hardlinks is the way to go. I see no downsides to that.



6.
You'll want to follow the re-process previously organized files using local xattr metadata guide to auto-generate the secondary structure. Since you'll match with xattr metadata and then hardlink the files, the process will be fairly instant.

:idea: Please read the FAQ and How to Request Help.
ye62dzec
Posts: 10
Joined: 09 Jan 2025, 16:24

Re: Formatting for private and plex use

Post by ye62dzec »

Hey rednoah,

thanks your your help!

I'll create two new threads for 1 and 4 - also, i will dive into 6 and hopefully find a satisfactory solution without a new thead :)


About question 2: The thing is, that I want to use relative pathing.

So for example I paste this movie to filebot:

Code: Select all

N:/Filme/Movie1 (2000)/Movie1 (2000).mkv
and rename it using the formatting from my initial post, the resulting structure is as follows:

Code: Select all

N:/Movie1 (2000)/Movie1 (2000).mkv
My movie is being dragged out of the N:/Filme Directory to the root of N.

This happens when a movie has no collection.

Any idea on how to fix that?

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

Re: Formatting for private and plex use

Post by rednoah »

ye62dzec wrote: 10 Jan 2025, 13:01 About question 2: The thing is, that I want to use relative pathing.
:?: Relative to what exactly though? Relative to the current drive? Relative to the parent folder of the movie file? Relative to a somehow specified folder level in between?

:idea: If you want to organise files into N:/Filme regardless of the current file path then the absolute path is what you want.




EDIT:

On further examination, you custom format is accidentally generating absolute file paths:

Format: Select all

{collection}/...

Code: Select all

/...
:!: If {collection} fails then the target file path will start with / which is an absolute file path on Linux, and evidently an "absolute-but-relative-to-the-drive" file path on Windows.
:idea: Please read the FAQ and How to Request Help.
ye62dzec
Posts: 10
Joined: 09 Jan 2025, 16:24

Re: Formatting for private and plex use

Post by ye62dzec »

Well. That's a good question in itself.

When renaming without {collection}, the movie folders always stay at the same directory they were initially stored in. In my case, all movies are usually at N:/Filme - before and after renaming.

Only when using {collection}, I run into the problem, that the movies are being dragged back to the root of N.

It's not that big of a deal, just wanted to let you know about the behavior and whether there is a way to fix it.

My assumption was, that I could just do a if-else whether there was a collection for a movie. If yes, use "{collection}/" as a prefix to {plex.name}, else don't use the prefix ;)

EDIT: Just saw your edit. Quite interesting! Is there an easy fix to that? What do you think about my if-else
User avatar
rednoah
The Source
Posts: 23743
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Formatting for private and plex use

Post by rednoah »

See EDIT above for details.


:arrow: You can use {folder} to generate absolute paths as desired for each file at hand:

Format: Select all

{folder}/{collection}/...
:arrow: Alternatively, you can not accidentally generate target file paths that start with / when {collection} is undefined like so:

Format: Select all

{ collection + '/' }
** see Learn how {expressions} work and useful Helper Functions for details
:idea: Please read the FAQ and How to Request Help.
ye62dzec
Posts: 10
Joined: 09 Jan 2025, 16:24

Re: Formatting for private and plex use

Post by ye62dzec »

Lovely! Thanks a million times!

Works like a charm :)

This is my current format in case anyone wants to copy it:

Code: Select all

{collection + '/'}{plex.name} - {audioLanguages.ISO2.joining(', ', '[', ']').upper()} {allOf{vf}{vc}{hdr.replace("Dolby Vision":"DV")}.joining(' ', ' [', ']')}/{plex.name} - {audioLanguages.ISO2.joining(', ', '[', ']').upper()} {allOf{vf}{vc}{hdr.replace("Dolby Vision":"DV")}.joining(' ', ' [', ']')}
Image
ye62dzec
Posts: 10
Joined: 09 Jan 2025, 16:24

Re: Formatting for private and plex use

Post by ye62dzec »

I set:

Code: Select all

filebot -script fn:properties --def net.filebot.xattr.store=.xattr
----
Load user-defined System Properties
* Read C:\Users\s\AppData\Roaming\FileBot\system.properties
Update user-defined System Properties
* Set net.filebot.xattr.store = .xattr
Store user-defined System Properties
* Write C:\Users\s\AppData\Roaming\FileBot\system.properties
#FileBot System Properties
#Sun Jan 12 23:37:49 CET 2025
net.filebot.xattr.store=.xattr

Done ヾ(@⌒ー⌒@)ノ
Result: 0
Unfortunately, xattr still doesn't work on my Windows System with a SMB Drive on N:

Code: Select all

WARNUNG: Failed to write xattr key: net.filebot.metadata: Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch: Back to the Future (1985) - [EN] [1080p x264] [15.7GB].mkv:net.filebot.metadata
Jan 12, 2025 11:33:26 PM net.filebot.MetaAttributeView put
WARNUNG: Failed to write xattr key: net.filebot.metadata: Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch: Back to the Future Part II (1989) - [EN] [1080p x264] [8.5GB].mkv:net.filebot.metadata
Jan 12, 2025 11:33:26 PM net.filebot.MetaAttributeView put
WARNUNG: Failed to write xattr key: net.filebot.metadata: Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch: Back to the Future Part III (1990) - [EN] [1080p x264] [9.3GB].mkv:net.filebot.metadata
Any idea what I'm doing wrong?



Also: is there a way to rename files for my prefered structure and automatically do a hardlink for every renamed file in my main dir at the same time?
User avatar
rednoah
The Source
Posts: 23743
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Formatting for private and plex use

Post by rednoah »

The error message strongly suggests that the setting is not in fact set. Each user has a different configuration file. Each machine has a different configuration file. Maybe something along those lines?

There is no easy way to apply multiple rename actions. You could of course - with significant effort - write our own custom a postprocess script, but the current solution is 2 clicks: Select Preset (or keyboard shortcut) and Rename
:idea: Please read the FAQ and How to Request Help.
ye62dzec
Posts: 10
Joined: 09 Jan 2025, 16:24

Re: Formatting for private and plex use

Post by ye62dzec »

I missed to check "Export .xattr folders" in the Post Processing Options. That fixed it.

Is is so complex to write a script?

I'd expect it to be as easy as:
1. Read all folders/files in "N:/Filme"
2. Fetch xattr Data
3. Make a hardlink match to "N:/Plex/Filme"
User avatar
rednoah
The Source
Posts: 23743
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Formatting for private and plex use

Post by rednoah »

The easiest solution would be the filebot command-line tool. You can have your postprocess script simply make a filebot call.


Re-process previously organized files using local xattr metadata

Shell: Select all

filebot -rename -r /input --db xattr --action hardlink --output /output --format "{plex.id}"

e.g. Run Command

Groovy: Select all

system 'filebot', '-rename', '--db', 'xattr', '--action', 'hardlink', '--output', '/output', '--format', '{plex.id}', *args


:!: Note that Export .xattr folders simply creates additional files with movie / episode metadata. This postprocess notably does not configure FileBot to read xattr information from .xattr folders, nor does it internally configure FileBot to use .xattr files for all kinds of xattr, e.g. original filename, mediainfo, crc32, custom user xattr, etc will still be stored (or attempted to be stored) into native file system xattr.
:idea: Please read the FAQ and How to Request Help.
Post Reply