How to retain a genre subdirectory when renaming

All about user-defined episode / movie / file name format expressions
Post Reply
storm
Posts: 1
Joined: 21 Dec 2021, 04:32

How to retain a genre subdirectory when renaming

Post by storm »

I am a new user of filebot, and am very impressed so far. This is one of those applications that is stealthily powerful, and the more you use it, the more you like it! My issue is that I would like to retain a "genre" subdirectory in the "TV Shows" or "Movies" directories when renaming, and have not been able to figure out how to construct a format expression for this. I'll give an example below.

Starting file structure and name:

Code: Select all

D:/Media/TV Shows/Detective & Drama/Cobra Kai/Season 3/Cobra.Kai.S03E09.1080p.NF.WEBRip.DDP5.1.x264-NTb.mkv
Using this format expression:

Code: Select all

D:/Media/{plex.id}
results in:

Code: Select all

D:/Media/TV Shows/Cobra Kai {tvdb-332858}/Season 03/Cobra Kai - S03E09 - Feel The Night.mkv
However, what we would really like is to retain the "Detective & Drama" folder:

Code: Select all

D:/Media/TV Shows/Detective & Drama/Cobra Kai {tvdb-332858}/Season 03/Cobra Kai - S03E09 - Feel The Night.mkv
The reason for this is we have a large media library that has been organized by my wife's own genre scheme that she would like to retain, for a use-case of using the Windows 10 File Explorer to locate the files and play them with VLC. The same library will be accessed by a Zidoo media player, which works fine with the genre subdirectory. Other types of genres are Comedy, Documentary & Reality, Fantasy, Sci Fi, Nature & Homes, Game Show, Horror, Music, Little Interest Shows, etc.

Note we also have some shows or movies that are not within a genre directory (they are at the root of the "TV Shows" or "Movies" directories). So the format expression needs to be flexible enough to work with or without the genre subdirectory. Thanks in advance for assistance in how to achieve this!
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to retain a genre subdirectory when renaming

Post by rednoah »

A.
You could pick the n-th path component from the original file path like so:

Code: Select all

f[2]
:idea: You may need some extra code if you need to dynamically decide which n-th path component to pick, if any all, depending on the file path at hand.



B.
You could match all the known genre patterns you want to keep from the file path:
viewtopic.php?t=12643

e.g.

Code: Select all

f.path.match(/Comedy|Documentary & Reality|etc/)

:idea: You can dynamically read the list of known genres / directory names directly from the genre parent folder:

Code: Select all

lines('X:/By Genre').find{ f =~ it }
:idea: Please read the FAQ and How to Request Help.
Post Reply