Renaming folders and files but NOT moving the folders

Any questions? Need some help?
Post Reply
DarthDaddy
Posts: 3
Joined: 06 Nov 2025, 18:13

Renaming folders and files but NOT moving the folders

Post by DarthDaddy »

Hi,

I have a large Jellyfin library, and I'm mostly happy with how the folders and files are named. But they could be better, so I purchased FileBot.

I can't for the life of me figure out how to rename folders and files, but keep the folders and files in place.

Filebot wants to move the folders to the root of my drive. I don't want this.

Currently I have:
  • Movies mostly in their own folder, with special features in a subfolder called "Featurettes"
  • Some movies folders are within other folders where it makes sense to me:
    Star Wars
    |---Star Wars Episode I - The Phantom Menace (1999)
    | |-- Star Wars Episode I - The Phantom Menace (1999).mkv
    | |-- Star Wars Episode I - The Phantom Menace (1999).eng.srt
    | |-- Featurettes
    | |-- How George Lucas Disappointed Us All.mkv
    |---Star Wars/Star Wars Episode II - Attack of the Clones (2002)
    | |-- Star Wars/Star Wars Episode II - Attack of the Clones (2002).mkv
    | |-- etc.
The problem is, Filebot is moving them all to:

D:\movies\Star Wars Episode I - The Phantom Menace (1999)
D:\movies\Star Wars Episode II - Attack of the Clones (2002)
etc.

Worse, the non-movie or subtitle files are staying in the original location with the original names. So now I have two locations for movie files.

I'm trying to rename the folder and files to have the title, year, tmdb ID, and, if exists, edition. (For instance, for Star Wars 4-6, I have both Special Edition and Despecialized Edition.)

This is the code I'm using for movies.

Code: Select all

{ ~jellyfin ** { " [tmdbid=$id]" } ** {if (edition) " - ["+{edition}+"]" else ""}}
I was hoping that the ~ before jellyfin would tell it to leave the folders in place, but it's not.

HELP ME PLEASE!!! I've searched this forum exhaustively for days, and asked chat GPT to no avail.

Thank you in advance!!!
User avatar
rednoah
The Source
Posts: 24261
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming folders and files but NOT moving the folders

Post by rednoah »

You could add {f.dir.dir} to the beginning of your format to generate exactly the absolute target file path you want.


Note that you will also need to enable “Import companion files” if you want to process folders like “Featurettes” alongside their corresponding movie file.


Note that you can also explicitly instruct FileBot to rename movie folders (as a single unit as if it was a single file) but that means processing folders and files separately in a 2-phase approach.
:idea: Please read the FAQ and How to Request Help.
DarthDaddy
Posts: 3
Joined: 06 Nov 2025, 18:13

Re: Renaming folders and files but NOT moving the folders

Post by DarthDaddy »

@rednoah, you're brilliant! Very helpful.

I changed my code to:

Code: Select all

{f.dir.dir}/{ ~jellyfin ** { " [tmdbid=$id]" } ** {if (edition) " - ["+{edition}+"]" else ""}}
The problem is that it is making unusual double folders.

To set this up, my "base" folder for testing FileBot is: D:\temp\jellyfin\Action\

For instance:

Back to the Future 2 is at: D:\temp\jellyfin\Action\Back to the Future Trilogy\Back to the Future Part II (1989)

FileBot wants to change it to: D:\temp\jellyfin\Action\Back to the Future Trilogy\Back to the Future Part II (1989)\Back to the Future Part II (1989) [tmdb=165]/Back to the Future Part II (1989) [tmdb=165].mkv

I bolded the folder that is a double and that doesn't belong.

You mentioned accomplishing what I want in two passes. I'm open to that.

Almost all my folders are named "Title (year)" and my movies are almost all "Title (year).mkv".

I just want to folders to be "Title (year) [tmdb=xxxxx] - [Director's Cut]" with the final part only being there is this is a special edition.
And then I want the filenames to be the exact same, but obviously with either mkv or mp4 or srt endings.

If that's accomplished in two passes, I'm fine with that. I don't want the folders to move; just be renamed.

I'm wracking my brain trying to get this to work, and I appreciate your help big-time!!!
User avatar
rednoah
The Source
Posts: 24261
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming folders and files but NOT moving the folders

Post by rednoah »

Where is the extra folder path name coming from?

f is the current file path. f.dir is the parent folder of that and so on.

Maybe you need to do f.dir.dir.dir to capture the folder path you want from the original file path?
:idea: Please read the FAQ and How to Request Help.
DarthDaddy
Posts: 3
Joined: 06 Nov 2025, 18:13

Re: Renaming folders and files but NOT moving the folders

Post by DarthDaddy »

Okay, I found what works 95%.

Code: Select all

{f.dir.dir}/{ ~jellyfin ** { " [tmdbid=$id]" } ** {if (edition) " - ["+{edition}+"]" else ""}}
But I have to make sure to only select the mkv mp4 and srt files. I manually unselect all the other files.

The other files are featurettes and various jpg poster files. If I unselect those, then everything seems to work.

I did have one collection not come out right.

Here are the "before" folders:

Action\The Bourne Collection
├───Jason Bourne (2016)
├───The Bourne Identity (2002)
├───The Bourne Legacy (2012)
├───The Bourne Supremacy (2004)
└───The Bourne Ultimatum (2007)

Here are the afters:

Action
├───Jason Bourne (2016) [tmdbid=324668]
├───The Bourne Identity (2002) [tmdbid=2501]
├───The Bourne Legacy (2012) [tmdbid=49040]
├───The Bourne Supremacy (2004) [tmdbid=2502]
└───The Bourne Ultimatum (2007) [tmdbid=2503]

It correctly added the tmdb id to the folder names (and to the mkv, mp4, and srt files within), but it removed the "The Bourne Collection" folder and placed the 5 movies in the root "Action" folder.

Weird since it didn't do that to similar collections, like Spiderman movies, Taken movies, Back to the Future trilogy.

It's fine. I manually recreated "The Bourne Collection" and moved the files there. I can live with that.

But the nerd in me doesn't like it. I want everything technical to just work. :D ;)
User avatar
rednoah
The Source
Posts: 24261
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming folders and files but NOT moving the folders

Post by rednoah »

f.dir.dir is simply "the parent folder of the parent folder of the file at hand" and that's it. If the file at hand is X:/A/B/C/D.txt then:

Code: Select all

f = X:/A/B/C/D.txt
f.dir = X:/A/B/C
f.dir.dir = X:/A/B
f.dir.dir.dir = X:/A
:idea: Your custom format therefore assumes a certain file structure. If the "the parent folder of the parent folder of the file at hand" logic works, then it works. If you add an extra Featurettes folders then the "the parent folder of the parent folder of the file at hand" logic no longer works. In this case you can write more code to to check the source path for certain conditions and the do different things depending on the specific file at hand.


:idea: That said, Featurettes, artwork, etc, are ignored when you do automatic movie matching, so those files typically wouldn't even have a movie match to be formatted, so no idea what's going on there.
:idea: Please read the FAQ and How to Request Help.
Post Reply