Edit name but keep extensions

Support for Windows users
Post Reply
redoXiD
Posts: 11
Joined: 14 Apr 2022, 21:52

Edit name but keep extensions

Post by redoXiD »

Hi there,

I am very new to FileBot and ran into a very annoying problem during my first renaming session.

Part of the problem is that I use German titles, as FileBot/TMDB sometimes doesn't rename the movies accordingly, but in theory this isn't a big problem, as you can rename the file manually. However, this is where the real problem starts: When I rename a file to the German title, FileBot automatically applies the new name to all files in the folder and overwrites the extensions of subtitles (e.g. .ger.forced), so you have to rename the subtitles manually afterwards, which is very time-consuming.

Here are two images for visualization:

English title
Image
becomes
Image

Is there any way to fix this problem so that FileBot applies the new name to all files but keeps the extensions? I already tried different naming schemes like {plex} but no luck so far.


Here is my current format preset:

Code: Select all

{n.colon(' - ')} ({y}) - {vf}{' CD'+pi}{any{subt}{f.subtitle ? fn =~ /forced/ ? '.ger.forced' : '.ger' : null}}
(I don't use {plex} or {plex.name} as it is harder to customize, especially subtitle extensions and keeping the folder name)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Edit name but keep extensions

Post by rednoah »

.sub and .idx is the file extension. FileBot will keep that by default. The .ger and .ger.forced is just what the file name ends with, i.e. the subtitle language suffix. Your custom format is responsible for this part. You are using {subt} in your format so it should work.


:?: If it does not work, then you are most likely not using the format that you have posted above. What do you see when you open the Format Editor via Double-Click ➔ Edit Format on a match that doesn't get formatted as expected?


:idea: {subt} works:

Code: Select all

$ filebot -mediainfo *.srt --format "{fn} => {subt}"
Avatar.2009.ger.forced => .ger.forced


:idea: Please include System Information to make sure that we are all using the same version of FileBot. Please read How to Request Help for details.
:idea: Please read the FAQ and How to Request Help.
redoXiD
Posts: 11
Joined: 14 Apr 2022, 21:52

Re: Edit name but keep extensions

Post by redoXiD »

Thanks for the clarification on extensions, suffix actually makes more sense.

I'm actually using the format I posted, and I also double-checked that beforehand. Changing it to just {subt} results in the same problem when renaming the files but also with missing suffixes for subtitles (as not all of my files have a language tag).
Image


Here is another example where I also show the renaming (makes no difference whether I rename the subtitle file or the mkv, the latter would result in no suffix at all for all files)
1.
Image
2. (I applied the exact German name as shown on TMDB)
Image
3.
Image


System Information

Code: Select all

FileBot 4.9.6 (r9125)
JNA Native: 6.1.2
MediaInfo: 21.09
7-Zip-JBinding: 16.02
Tools: fpcalc/1.5.0
Extended Attributes: OK
Unicode Filesystem: OK
Script Bundle: 2022-04-11 (r811)
Groovy: 3.0.9
JRE: OpenJDK Runtime Environment 17.0.2
JVM: OpenJDK 64-Bit Server VM
CPU/MEM: 12 Core / 3.7 GB Max Memory / 92 MB Used Memory
OS: Windows 10 (amd64)
STORAGE: NTFS [(C:)] @ 11 GB | FAT32 [Google Drive] @ 6 GB | NTFS [home] @ 2.6 TB | NTFS [Download] @ 2.6 TB | NTFS [video] @ 2.6 TB
DATA: C:\Users\arvid\AppData\Roaming\FileBot
Package: MSI
License: UNREGISTERED
Haven't bought a license yet, will do it as soon as everything works as expected.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Edit name but keep extensions

Post by rednoah »

Can you point out a specific issue in any of the screenshots you have posted? Looks like the language suffix is correctly added for every single item in the New Names list via one of the code paths in your custom format.

☑️ All non-subtitles file do not have (and should not have) subtitle language suffixes.
☑️ All subtitle language suffixes seem to be correct, where .eng is detected from the original file via {subt} and .ger or .ger.forced is added generically for files via your custom code in cases where {subt} is undefined.
redoXiD wrote: 15 Apr 2022, 09:26 Image

:idea: {subt} won't work for image-based subtitles (i.e. idx / sub pairs) because FileBot does not do OCR. The subtitle file must already have a language suffix so FileBot can detect the language based on that, or be text-based so that FileBot can look at the text and detect the language based on that. If {subt} doesn't work, then your format will just add .ger or .ger.forced - depending on the file at hand - for any and all subtitle files.


:?: I notice strange things in the dark mode screenshot you first posted, but I'm fairly sure that you're just using a different format which forces .ger for all subtitle files there. You can inspect different aspects of your format code in Format Editor like so. See the value of {fn}, see what {subt} returns, see what your custom detection code does, etc.

Image



EDIT:

:?: Are you perhaps having trouble specifically with the Edit Name feature? (independent and unrelated to custom formatting)
redoXiD wrote: 15 Apr 2022, 09:26 Image
:arrow: If you want German movie names names, then manually typing them is not the way to go. You'll want to set Preferences ➔ Language ➔ German if you want German movie names.


EDIT 2:

I see. If you first match files up, everything works. But if you then manually force a different file name for an individual item, FileBot will apply the updated name to all subsequent items that have the same movie match. I can see how that's not the behaviour we want in this particular corner case. I'll look into it.

There might not be a good solution. You definitely want the current behaviour (i.e. Edit Name on the *.mkv changes the file name on all the other items) because you don't wanna enter the file name for every single item. If you use Edit Name then you just need to do it top-down and edit things as needed (sometimes too much, but you can edit that too when you get to that row). Notably, once you click on Edit Name then your format becomes irrelevant.

That said, you should never need Edit Name in the first place, and always preemptively generate the correct file paths you want via your custom format, not by manually entering things.
:idea: Please read the FAQ and How to Request Help.
redoXiD
Posts: 11
Joined: 14 Apr 2022, 21:52

Re: Edit name but keep extensions

Post by redoXiD »

:arrow: If you want German movie names names, then manually typing them is not the way to go. You'll want to set Preferences ➔ Language ➔ German if you want German movie names.
I already did that when I created the preset. I guess FileBot sometimes has problems to fetch the correct name from TMDB (since the German name is also correctly entered there). Fortunately this doesn't affect all files, most of them are renamed with the correct name, but still very inconsistent with up to ~20% renamed incorrectly (which is a lot if you have a library with hundreds of movies).
EDIT 2
...
Yes, that's right. I'm sorry if I've been a little unclear.

Thanks for the clarification on the behavior of the "Edit Name" function, at least now I understand what FileBot does. So apparently I have to keep renaming the indivdual files.
To make this process easier, would it be possible to integrate a feature to rename the match itself, so that the custom format uses the edited name of the match? This could also be very useful in case prefer an alternate title for your movies.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Edit name but keep extensions

Post by rednoah »

1.
You can do SHIFT+CLICK <Edit Match> to edit the currently selected item exclusively. That way, you'll have to edit each item individually though.
rednoah wrote: 21 Jul 2021, 03:08 SHIFT+CLICK <Edit Match | Edit Name> ... Disable column auto-fill (i.e. edit the currently selected instance but not subsequent instances)
EDIT: FileBot r9188 improves autofill behaviour for Edit Name by re-applying changes to subsequent items (if possible) rather than just overwriting the value with the one entered.


2.
Your format code can do anything. For example, your format code can check the movie name, and then spit out some arbitrary different value in response:
viewtopic.php?t=182

e.g. just a simple example; a good solution would likely utilize external *.csv files for easy maintenance:

Code: Select all

{
	n.replace(
		/Avatar/ : /ABC/,
		/On Her Majesty's Secret Service/ : /XYZ/
	)
}
:!: Unfortunately, a "force some binding value and re-format" feature for all the 100+ bindings (many of which are not simple String or Integer values) is not feasible. Best to have your format generate the correct path (with custom code and external *.csv files if necessary) in the first place.



3.
redoXiD wrote: 15 Apr 2022, 14:55 I guess FileBot sometimes has problems to fetch the correct name from TMDB (since the German name is also correctly entered there)
This would be a bug. Can you provide a reproducible test case?
:idea: Please read the FAQ and How to Request Help.
redoXiD
Posts: 11
Joined: 14 Apr 2022, 21:52

Re: Edit name but keep extensions

Post by redoXiD »

Thank you very much, this was very helpful! I actually didn't know you could change the name using the format so easily, it would have saved me a lot of time... ;)
I'm looking forward to test the r9188 beta version as soon as it becomes available, hopefully it works and improves the behavior as expected.

This would be a bug. Can you provide a reproducible test case?
Sure, here are two examples:

Files/directory:

Code: Select all

Y:\complete\The.North.Sea.2021.German.1080p.BluRay.x264-LizardSquad
	the.north.sea.2021.german.1080p.bluray.x264-lizardsquad-forced.idx
	the.north.sea.2021.german.1080p.bluray.x264-lizardsquad-forced.sub
	the.north.sea.2021.german.1080p.bluray.x264-lizardsquad.idx
	the.north.sea.2021.german.1080p.bluray.x264-lizardsquad.mkv
	the.north.sea.2021.german.1080p.bluray.x264-lizardsquad.nfo
	the.north.sea.2021.german.1080p.bluray.x264-lizardsquad.sub

Code: Select all

Y:\complete\James.Bond.007.Im.Geheimdienst.Ihrer.Majestaet.1969.German.DL.1080p.BluRay.x264-DETAiLS
	d-majestaet-1080p-eng.idx
	d-majestaet-1080p-eng.sub
	d-majestaet-1080p-forced.idx
	d-majestaet-1080p-forced.sub
	d-majestaet-1080p-subs.sfv
	d-majestaet-1080p.idx
	d-majestaet-1080p.mkv
	d-majestaet-1080p.nfo
	d-majestaet-1080p.sub
Preset used:

Code: Select all

{n.colon(' - ')} ({y}) - {vf}{' CD'+pi}{any{subt}{f.subtitle ? fn =~ /forced/ ? '.ger.forced' : '.ger' : null}}
Image

The results:
Image

Image

The correct German names would be "The North Sea" and "James Bond 007 - Im Geheimdienst Ihrer Majestät", which are also shown on the TMDB website.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Edit name but keep extensions

Post by rednoah »

I see. Presumably, there's a IMDB or TheMovieDB link in the *.nfo file, and FileBot seems to not respect your language preferences when doing a lookup that way. Your screenshots would support that theory since one folder has an *.nfo file and the other does not. I will look into it.

EDIT: Fixed with FileBot r9192.


In the meanwhile, you can just dynamically localize at format time:
viewtopic.php?t=3761

e.g.

Code: Select all

{ localize.de.n }
:idea: Please read the FAQ and How to Request Help.
Post Reply