CLI: How to output *only* the new name?

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
fbotguy
Posts: 7
Joined: 20 Jan 2023, 10:21

CLI: How to output *only* the new name?

Post by fbotguy »

With a command like:

Shell: Select all

$ filebot --action test --db TheMovieDB -rename *.mkv
The output is very noisy, like:

Console Output: Select all

WARNING: java.io.tmpdir directory does not exist
* Consider using --mode interactive to enable interactive mode
Rename movies using [TheMovieDB]
[TEST] from [/path/to/The.Example.Movie.2024.mkv] to [/path/to/The Example Movie (2024).mkv]
Processed 1 file
How can I get it to output

Code: Select all

The Example Movie (2024)
and nothing else?
User avatar
rednoah
The Source
Posts: 23923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: CLI: How to output *only* the new name?

Post by rednoah »

:?: What is your use case? Presumably you want to use filebot as part of some other script that does something for some reason?


:idea: You could use --log INFO to reduce the number of lines in the console output. The format of each line however cannot be modified. That said, whatever it is you're trying to do, there's probably a different way to go about it. Perhaps with the -exec option. Perhaps with the -mediainfo in a second step. Perhaps something else, depending on the specifics if what you're trying to do.
:idea: Please read the FAQ and How to Request Help.
fbotguy
Posts: 7
Joined: 20 Jan 2023, 10:21

Re: CLI: How to output *only* the new name?

Post by fbotguy »

You guessed it right: I'm trying to call filebot from another script. I have an unusual filesystem situation so filebot's own rename/symlink structures don't quite work for me. So I'm writing a program that uses filebot only to identify the "clean name" of a given media file.

--log INFO removes the "Consider using.." line, but nothing else.
User avatar
rednoah
The Source
Posts: 23923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: CLI: How to output *only* the new name?

Post by rednoah »

fbotguy wrote: 10 Mar 2025, 17:19 --log INFO removes the "Consider using.." line, but nothing else.
Here's what I get:

Console Output: Select all

$ filebot -rename *.mkv --db TheMovieDB -non-strict --action TEST --log INFO
[TEST] from [Avatar.mkv] to [Avatar (2009).mkv]



fbotguy wrote: 10 Mar 2025, 17:19 I have an unusual filesystem situation so filebot's own rename/symlink structures don't quite work for me.
:?: What is the rename/symlink structure you're trying to achieve? Can you express what you want to do as shell script?

:arrow: A Custom Rename Action will likely do the trick. Please do share your code with us, for the next guy.
:idea: Please read the FAQ and How to Request Help.
fbotguy
Posts: 7
Joined: 20 Jan 2023, 10:21

Re: CLI: How to output *only* the new name?

Post by fbotguy »

rednoah wrote: 10 Mar 2025, 17:38 Here's what I get:
Mine is similar, just with an extra "WARNING: java.io.tmpdir directory does not exist" but that's fine.
rednoah wrote: 10 Mar 2025, 17:38 :?: What is the rename/symlink structure you're trying to achieve? Can you express what you want to do as shell script?

:arrow: A Custom Rename Action will likely do the trick. Please do share your code with us, for the next guy.
Thanks, I'll check out custom actions. I have a media directory that has multiple concurrent writers, so executing a rename / creating a symlink arbitrarily can break other users of the directory. That's why I'm writing a little app in Go that serializes all writes into this directory so there is only ever one write at a time. That's why I don't want filebot to execute any actions itself - I just want it to tell me the clean name of the file so I can do everything from within my app.
User avatar
rednoah
The Source
Posts: 23923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: CLI: How to output *only* the new name?

Post by rednoah »

fbotguy wrote: 10 Mar 2025, 18:43 I have a media directory that has multiple concurrent writers, so executing a rename / creating a symlink arbitrarily can break other users of the directory.
You can do something like this:

Shell: Select all

--action /usr/local/bin/my-synchronized-move-program
FileBot will pass old file path and new file path as $1 and $2 and then the rest is up to your program.



fbotguy wrote: 10 Mar 2025, 18:43

Console Output: Select all

WARNING: java.io.tmpdir directory does not exist
You can do filebot -script fn:sysenv to see what file path java.io.tmpdir is in your environment. You can then create a folder at that file path and the warning message will go away.
:idea: Please read the FAQ and How to Request Help.
fbotguy
Posts: 7
Joined: 20 Jan 2023, 10:21

Re: CLI: How to output *only* the new name?

Post by fbotguy »

Perfect, thank you :)
Post Reply