[FileBot Node] Preserve part of the input filename

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
trininja
Posts: 14
Joined: 08 Oct 2019, 12:29

[FileBot Node] Preserve part of the input filename

Post by trininja »

Okay, I am about to reorganize some thousand files. And with these files there are a lot of metadata in a special format.

xxxxxxx-poster.xxx
xxxxxxx-banner.xxx
xxxxxxx-clearart.xxx
xxxxxxx-logo.xxx
xxxxxxx-thumb.xxx
xxxxxxx-fanart.xxx
....

You get it I think.

For movies it will get already dirty. For episodes? I won't imagine that, because I also have Season1-banner, Season2-banner and so on files. but let's ignore these for a while. *sigh*

My question is: Is there a way to tell FileBot to preserve parts of a filename? i.e. if the filename has a word -poster in it, append the word -poster to the filename recreated and so on for everything. I could do the dirtywork and reorganize everything for two or three weeks in MediaElch with 16hour shifts a day.....but yeah, if there is a way in FileBot. ;)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Preserve part of the input filename

Post by rednoah »

If you have files like this:

Code: Select all

Avatar.avi
Avatar-poster.jpg
Avatar-fanart.png
Then it will work as expected (the video will get matched, the extras get auto-matched to the same match as the corresponding primary video file) but you have'll have to use fn.match(/poster|fanart/) in your format to preserve those tokens in the destination path as well (or not, depending on your preferences).
:idea: Please read the FAQ and How to Request Help.
trininja
Posts: 14
Joined: 08 Oct 2019, 12:29

Re: Preserve part of the input filename

Post by trininja »

Okay, I admit, I am to new to this whole thing, all I did for a long time was basic renaming and moving, I never worked into the real heavy parts of FileBot scripting. Seems I have to do some really weired work.

And I have another problem I do not understand, maybe I oversee something: I work with FileBot Node, not the pure CLI. It seem it only takes the mediafile (.mkv, .mov, .avi, .mp...) and the subtitle files...the rest is complete ignored.

Actually I also try to figure out how I can extend this snippet

Code: Select all

{y > 2010 ? y : y > 1999 ? '2000 - 2010' : '19xx - 1999'}
to work for more ranges i.e 1950-1959, 1960-1969, and so on..... *bigfacepalm*

My actual not "working" string is

Code: Select all

filebot -script 'fn:amc' '/volume1/video/Filme/Harry Potter' --output /volume1/JDown/Filme --action TEST -non-strict --conflict override --lang de --def 'ut_label=Movie' 'subtitles=deu' 'skipExtract=y' 'minFileSize=0' 'movieFormat={y > 2010 ? y : y > 1999 ? '\''2000 - 2010'\'' : '\''19xx - 1999'\''}/{n.ascii()} ({y}){width > 3000 ? '\'' UHD'\'' : null}/{n.ascii()} ({y}){width > 3000 ? '\'' UHD'\'' : null}{fn.match(/-logo|-poster|-clearart|-trailer|-thumb|-fanart|-banner|-clearlogo|-disc|-discart|-landscape|-320-10/)}' --log all --log-file '/usr/local/filebot-node/data/filebot.log'
I preworked it in FileBot Node and than tested it with the unecessary stuff stripped out in the CLI, the result you can see in the screenshot. On the right is the sourcefolder with the images and other stuff.

Image
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Preserve part of the input filename

Post by rednoah »

:!: This thread is now about FileBot Node. Previous posts assume that you're using the FileBot Desktop application.


1.
FileBot Node is using the amc script which is designed for automation of newly added files. It will ignore files for various reasons as to avoid mismatches.

:idea: You'll want to use the FileBot GUI for any kind of one-off media organization operation. FileBot Node is designed to help you set up unattended automation and is cumbersome for hands-on tasks.


2.
DO USE the GUI when prototyping format expressions, unless you are a god that can write flawless code. I'm not, so I use the Format Editor. :lol:

Image


EDIT:

Here's what I came up with:

Code: Select all

{def c = (y / 10).trunc(); "${c}0-${c}9"}
:idea: Please read the FAQ and How to Request Help.
trininja
Posts: 14
Joined: 08 Oct 2019, 12:29

Re: [FileBot Node] Preserve part of the input filename

Post by trininja »

So, playing around a bit I think I have to give FileBot all the files as input by "hand" manually. Another problem I found by testing a bit with the desktop application is, that trailer files get ignored...I tested them in FileBot Node as well, the trailers are mp4/webm files and yes, there also they get ignored.

And thanks for this awesome snippet ;) You are a real god of the syntax ;)

Yeah, I actually play around with the desktop application and the builder, but...my problem is the input of files. I have around 5000 movies to rename. with around 40000 metadata files along. I don't know if this will crash FileBot. I had the problem yesterday already sometimes with around 1000 files. All already scrapped, but sorted in a chaotic way. Some names are in n - y - genre format, others are in ny, others are in y -n and so on, but all are proper named already corresponding to their MovieDB entry. he nfo files are all generated also (That will be the next problem I have to deal with, the filenames are hard coded into the nfos, so I will have to find a way to deal with this also...or do the dirty work and just ignore all input, rename only the moviefiles, try to get the trailers also and re scrap everything with MediaElch for my Kodis. Holy molly....can someone hand me over a gun.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [FileBot Node] Preserve part of the input filename

Post by rednoah »

1.
5k files isn't that many. Should be fine. But if you're worried, run with console so you can see what the output says, just in case you get any runtime errors.


2.
-trailer and -sample files get ignored. There's a small number of built-in patterns that are completely ignored by default. Those two are pretty much it, and maybe Anime OP/ED videos.


3.
If you have lots of files, then I recommend a 2-pass approach, use strict mode the first time around and let it pick out all the easy matches (and fill the caches with lots of info about all your files) and then do a second pass on the rest where you'll want to double-check things here and there:
viewtopic.php?t=4695
:idea: Please read the FAQ and How to Request Help.
trininja
Posts: 14
Joined: 08 Oct 2019, 12:29

Re: [FileBot Node] Preserve part of the input filename

Post by trininja »

Yeah, thought that with the strict mode, even when I have stripped out the special chars with the ascii() function to stay clean for most systems connected. Hm, mutltipass approach is better, yeah. I think about it. ;)

For the trailers, I feared that. >_< I have them stored locally since some trailers disappear sometimes from the net, reduced quality or other things. So I stored them locally for my reasons, around 5000 trailers. xD Any chance to include them somehow with the desktop client for MAC? Sample files is alway good. I hate them. ;)

Console is sometimes the only way to test things. :) Hope I can get around this with the things I want.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [FileBot Node] Preserve part of the input filename

Post by rednoah »

If you're using the CLI, then you can add --apply import (in development, feedback is welcome, requires the latest FileBot 4.8.6 revision) to your command and that'll then copy over sibling files from the original folder to the destination folder after renaming independent of renaming:
viewtopic.php?t=11079
:idea: Please read the FAQ and How to Request Help.
trininja
Posts: 14
Joined: 08 Oct 2019, 12:29

Re: [FileBot Node] Preserve part of the input filename

Post by trininja »

I did it the hard way: Desktop, around 3000 Files at once, more and it crashed on me on my Mac (iMac 2019, i5 with 32GB RAM.), Afterwards I batch reloaded and rewrote the NFOs with MediaElch all at once with the option that only files with a MovieDB entry are allowed to get updated. Problem solved in the end.

No I have Filebot Node on my Synology clean running with the string you helped me with (And where I do not need the fn.match() anymore, but the UHD and def part ;)) and its all up and running. Thank you again. I concider buying 2-3 single licence for a year on top to support you further, even when I do not need them and continue that way.;)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [FileBot Node] Preserve part of the input filename

Post by rednoah »

I'm really curious about those crashes. Like it freezes? Or it literally crashes with a crash log? Can you run filebot via console and try again and see what happens? What does the console log say when it crashes?

No worries. Just get one every year and it's all good, and see if you can get me these crash logs. ;)
:idea: Please read the FAQ and How to Request Help.
Post Reply