Page 1 of 1

preserving Collection subfolder names when mixed with single movie subfolders

Posted: 09 Oct 2024, 11:03
by yhm28
For example a set of movies, where each movie is in an identically named parent folder, with some grouped into "Collection" folders

Code: Select all

Movies/ (top folder)
Movie 1 (year)/Movie 1 (year).mkv
Movie 2 (year)/Movie 2 (year).mkv
Movie 3 (year)/Movie 3 (year).mkv
# COLLECTION - Superman/ (subfolder within Movies)
Superman Movie 1 (year)/Superman Movie 1 (year).mkv
Superman Movie 2 (year)/Superman Movie 2 (year).mkv
Superman Movie 3 (year)/Superman Movie 3 (year).mkv
What expression (if any) can preserve this structure? Or will I have to do each "Collection" folder individually?

Re: preserving Collection subfolder names when mixed with single movie subfolders

Posted: 09 Oct 2024, 12:31
by rednoah
:idea: You can use {folder} to use the current folder in your format.


e.g. rename files in place, explicitly by generating absolute file paths with the same parent folder path:

Format: Select all

{ folder }/{ plex.name }


:idea: You can do things like folder[0..2] or folder[-3..-1] or folder[1..-2] to get the first N or last N or N in-between path components, but you may find it difficult to programmatically know if a file path contains a collection folder or not and which specific folder levels are part of the path you want to preserve. In this case I'd probably just do "take everything after the /Movies/ bit" like so:

Format: Select all

{ folder.path.after(/[\/\\]Movies[\/\\]/) }


:idea: {relativeFile} may also work, but this one is more magical as it relies on FileBot internals to detect the "structure root" folder to then take the remaining file path from there:

Format: Select all

{ relativeFile.dir }