Page 1 of 1
CLI: How to output *only* the new name?
Posted: 10 Mar 2025, 15:43
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
and
nothing else?
Re: CLI: How to output *only* the new name?
Posted: 10 Mar 2025, 17:14
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?

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.
Re: CLI: How to output *only* the new name?
Posted: 10 Mar 2025, 17:19
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.
Re: CLI: How to output *only* the new name?
Posted: 10 Mar 2025, 17:38
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?

A
Custom Rename Action will likely do the trick. Please do share your code with us, for the next guy.
Re: CLI: How to output *only* the new name?
Posted: 10 Mar 2025, 18:43
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?

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.
Re: CLI: How to output *only* the new name?
Posted: 11 Mar 2025, 00:24
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.
Re: CLI: How to output *only* the new name?
Posted: 11 Mar 2025, 08:44
by fbotguy
Perfect, thank you
