Q&A for n00bs

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
User avatar
rednoah
The Source
Posts: 14942
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Q&A for n00bs

Post by rednoah » 17 Oct 2016, 07:37

The filebot command-line tools are simple and very basic skill will get you a long way, but there is an increasing number of threads from users that don't seem to know anything about Cmdline and Argument Passing and thus clutter up the forums with reports about "filebot not working" when it's just a typical "user does not know how to use the command line" kind of issue that has nothing to do with filebot specifically.

  • $PATH not set resulting in filebot: command not found issues (hard to find if you don't see the error output)
  • Not quoting arguments that contain spaces > C:/Program Files/FileBot/filebot.exe -version ⇨ C:/Program: command not found
  • Not escaping quotes in quoted arguments (--format "..."..."...")
  • Accidentally escaping arguments (filebot -rename "C:\files\" --action test)
  • “...” being used instead of "..." (apparently some command-line calls are written in Microsoft Word or Apple Pages)
  • '...' used to quote arguments on Windows (blind copy & paste from examples for Linux or Mac)
  • Literally passing in %D or %F as input arguments (filebot cannot magically resolve substitution patterns from 3rd party programs)
  • Using {fn} (the current filename) in your format and then wondering why filebot does not rename files (blind copy & paste of format examples)
  • Permission issues on Linux (always tricky but never an issue specific to filebot)
  • The process cannot access the file because it is being used by another process issues on Windows (wretched OS limitations)

FileBot does have an easy-to-use GUI that can be used by anybody. The filebot command-lines tools designed for advanced users that have at least basic command-line skills. It is perfectly OK to stick to the GUI if the command-line seems daunting, but if you decide to spend a bit of time with the command-line you will find it to be easy and invaluable for any kind of automation. ;)

However, as mentioned in How to 'Request Help' I may not have the time (or patience) to personally hand-hold every single user with taking their first baby steps with the command-line. Besides, some things you just need to figure out yourself to really understand them. ;)
rednoah wrote:Make sure you escape and quote your cmdline arguments correctly. I will not fix your broken cmdline call for you.
rednoah wrote:When redirecting console output, make sure to include standard output AND error output. I will not fix your command not found issues.

Tips & Tricks:
:idea: Please read the FAQ and How to Request Help.

Divc09
Posts: 7
Joined: 22 Oct 2016, 11:32

Deluge Amc Script not working

Post by Divc09 » 24 Oct 2016, 18:02

I've looked on the forum for hours and I have somehow managed to create a script (don't know any programming) without any issues but it does not do anything on execution. Even on testing directly through command line is says that there are no files selected for processing. I don't know how to select a file to run the script on and if I change ut_file and ut_dir to the file name and directory then the there is another error which says that there is some problem with ut_kind.
It is for deluge on windows 7.
Here is the script -

Code: Select all

filebot -script fn:amc --output "F:/not sorted" --log-file amc.log --action test --conflict override -non-strict --def  deleteAfterExtract=y subtitles=en unsorted=y excludeList=amc.txt "ut_dir=%3/%2" "ut_kind=multi" "ut_title=%2" "ut_label=%L"
Here is the output on testing -

Code: Select all

Parameter: deleteAfterExtract = y
Parameter: subtitles = en
Parameter: unsorted = y
Parameter: excludeList = amc.txt
Parameter: ut_dir = %3/%2
Parameter: ut_kind = multi
Parameter: ut_title = %2
Parameter: ut_label = %L
Using excludes: F:\not sorted\amc.txt (0)
No files selected for processing
Failure (┬░_┬░)
Please help if someone knows how to get it working. I have wasted a lot of hours to get this working and cannot find how to make it work. Thanks.

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

Re: Deluge Amc Script not working

Post by rednoah » 24 Oct 2016, 18:16

:idea: If you can't manage to run the script from CMD on a few files yourself, then you will never be able to make it work with 3rd party programs. I highly recommend that you play with it in CMD first so you understand how it works before you attempt to write CMD scripts for 3rd party programs.

Divc09 wrote:

Code: Select all

Parameter: ut_dir = %3/%2
Parameter: ut_kind = multi
Parameter: ut_title = %2
Parameter: ut_label = %L
:?: Where are these %VARIABLES supposed to come from? As the Deluge example is for Linux and Mac only, you'll probably need some basic Windows CMD skills if you want to make it work.

rednoah wrote:Troubleshooting
If something is not working, first read the Notes above, then just run the command manually in a new console window and see what happens. You CANNOT run the command without replacing the VARIABLES. The variables have to be replaced with actual values first.

It's always helpful to check the exact command utorrent ends up executing in the Logger tab. It'll look something like this:

Code: Select all

[2013-03-05 20:44:24]  Executing: filebot -script fn:amc --output "D:/Organized Media" --log-file amc.log --action duplicate --conflict override -non-strict --def "ut_dir=D:\Media\Avatar" "ut_file=" "ut_kind=multi" "ut_title=Avatar" "ut_label=" "ut_state=5"
:idea: Did you read the Troubleshooting section yet? Note that the actual command-line call that is executed does not contain any kind of %PLACEHOLDER but actual paths and values instead.
:idea: Please read the FAQ and How to Request Help.

SN23
Posts: 3
Joined: 01 Jun 2014, 01:12

Filebot script- bad file arguments

Post by SN23 » 28 Oct 2016, 23:11

I had a previous version of filebot installed and it worked perfectly with the script using transmission.

Script

Code: Select all

#!/bin/bash
filebot -script fn:amc --output "path to media" --log-file amc.log --action copy --conflict override -non-strict --def "ut_dir=$TR_TORRENT_DIR/$TR_TORRENT_NAME" "ut_kind=multi" "ut_title=$TR_TORRENT_NAME"ls
And this is the output from the command line

Code: Select all

Run script [fn:amc] at [Fri Oct 28 19:09:36 EDT 2016]
Parameter: ut_dir = /
Parameter: ut_kind = multi
Parameter: ut_title = ls
Illegal usage: bad file arguments or ut_dir/ut_file parameters
Failure (°_°)
Any help would be appreciated

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

Re: Filebot script- bad file arguments

Post by rednoah » 29 Oct 2016, 01:25

You're trying to process your entire filesystem, which is most certainly not what you wanna do (and if FileBot didn't do a sanity check before doing what you tell it to do it'd ruin your system). ;)
rednoah wrote:Troubleshooting
If something is not working, first read the Notes above, then just run the command manually in a new console window and see what happens. You CANNOT run the command without replacing the VARIABLES. The variables have to be replaced with actual values first.
This script must be called by Transmission (but it's not) because the TR_* environment variables must be set (but they aren't).

FYI: not replying to questions is not appreciated.
:idea: Please read the FAQ and How to Request Help.

SN23
Posts: 3
Joined: 01 Jun 2014, 01:12

Re: Q&A for n00bs

Post by SN23 » 30 Oct 2016, 04:15

I got my script working, I had just forgotten to give the shell script the execute permission. I'm Sorry about not responding to my last post.

russco
Posts: 14
Joined: 17 Nov 2014, 17:58

Notifying XBMC/Kodi

Post by russco » 01 Nov 2016, 12:58

Hi there,

So notifying XBMC/Kodi recently stopped working. Here's what runs when a torrent finishes:
"C:\Program Files\FileBot\filebot.launcher.exe" -script fn:amc --output "F:" --def "seriesFormat=F:/TV/{n}/{'Season '+s}/{n} - {sxe} - {t}{'.'+lang}" "movieFormat=F:/Films/{n}" --log-file amc.log --action copy --conflict override -non-strict --def music=y "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D" --def xbmc=127.0.0.1
Is it maybe because it should now be --def kodi=127.0.0.1 instead? Or should it stay as xbmc?

I tried running this from cmd and seemingly nothing happened.

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

Re: Notifying XBMC/Kodi

Post by rednoah » 01 Nov 2016, 13:38

Thanks for the post! Before a real human comes by, please make sure your report has all the following points checked:
  • What are you trying to do achieve? What's not working? What have you tried so far?
  • Include screenshots, logs or filenames (i.e. demonstrate the issue)
  • Include basic information (i.e. sysinfo output)
:idea: Please read How to Request Help and Fix Problems, Report Bugs, Get Features
:idea: Please read the FAQ and How to Request Help.

russco
Posts: 14
Joined: 17 Nov 2014, 17:58

Re: Notifying XBMC/Kodi

Post by russco » 01 Nov 2016, 13:53

Here's my sysinfo:

Code: Select all

C:\Users\Russ>filebot -script fn:sysinfo
FileBot 4.7.2 (r4178)
JNA Native: 4.0.1
MediaInfo: 0.7.78
7-Zip-JBinding: 9.20
Chromaprint: 1.1.0
Extended Attributes: OK
Script Bundle: 2016-10-31 (r448)
Groovy: 2.4.7
JRE: Java(TM) SE Runtime Environment 1.8.0_91
JVM: 64-bit Java HotSpot(TM) 64-Bit Server VM
CPU/MEM: 8 Core / 1 GB Max Memory / 54 MB Used Memory
OS: Windows 7 (amd64)
Package: MSI
Data: C:\Users\Russ\AppData\Roaming\FileBot
Done ?(?????)?

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

Re: Notifying XBMC/Kodi

Post by rednoah » 01 Nov 2016, 14:06

The logs (i.e command-line output) would be nice.
:idea: Please read the FAQ and How to Request Help.

russco
Posts: 14
Joined: 17 Nov 2014, 17:58

Re: Notifying XBMC/Kodi

Post by russco » 01 Nov 2016, 14:11

When I paste this at the command prompt:
"C:\Program Files\FileBot\filebot.launcher.exe" -script fn:amc --output "F:" --def "seriesFormat=F:/TV/{n}/{'Season '+s}/{n} - {sxe} - {t}{'.'+lang}" "movieFormat=F:/Films/{n}" --log-file amc.log --action copy --conflict override -non-strict --def music=y "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D" --def xbmc=127.0.0.1
And hit enter, nothing happens or shows up. It just goes back to the command prompt.

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

Re: Notifying XBMC/Kodi

Post by rednoah » 01 Nov 2016, 16:08

Don't use filebot.launcher.exe if you don't know what you're doing. ;)

On Windows, GUI executables don't get a console. CLI executables (e.g. filebot.exe) do.


EDIT: Read this while you're at it: viewtopic.php?f=4&t=4239


EDIT 2: All of this will probably just result in us finding out that you didn't enable the HTTP API in Kodi settings.
:idea: Please read the FAQ and How to Request Help.

russco
Posts: 14
Joined: 17 Nov 2014, 17:58

Re: Notifying XBMC/Kodi

Post by russco » 01 Nov 2016, 17:35

Okay, here's the latest:

Code: Select all

C:\Users\Russ>"C:\Program Files\FileBot\filebot.exe" -script fn:amc --output "F:
" --def "seriesFormat=F:/TV/{n}/{'Season '+s}/{n} - {sxe} - {t}{'.'+lang}" "movi
eFormat=F:/Films/{n}" --log-file amc.log --action copy --conflict override -non-
strict --def music=y "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_
file=%F" "ut_dir=%D" --def xbmc=127.0.0.1
Locking C:\Users\Russ\AppData\Roaming\FileBot\logs\amc.log
Run script [fn:amc] at [Tue Nov 01 18:33:30 CET 2016]
Parameter: seriesFormat = F:/TV/{n}/{'Season '+s}/{n} - {sxe} - {t}{'.'+lang}
Parameter: movieFormat = F:/Films/{n}
Parameter: music = y
Parameter: ut_label = %L
Parameter: ut_state = %S
Parameter: ut_title = %N
Parameter: ut_kind = %K
Parameter: ut_file = %F
Parameter: ut_dir = %D
Parameter: xbmc = 127.0.0.1
Bad ut_label value: %L
Bad ut_state value: %S
Bad ut_title value: %N
Bad ut_kind value: %K
Bad ut_file value: %F
Bad ut_dir value: %D
Illegal usage: no input
Failure (┬░_┬░)

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

Re: Notifying XBMC/Kodi

Post by rednoah » 01 Nov 2016, 17:44

rednoah wrote:Read this while you're at it: viewtopic.php?f=4&t=4239
READ THIS LINK.


PS: --def kodi (preferred) and --def xbmc (for backwards compatibility) are both supported and work fine.
:idea: Please read the FAQ and How to Request Help.

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

Re: Q&A for n00bs

Post by rednoah » 01 Nov 2016, 18:27

1.
The Troubleshooting section thoroughly explains why your command is wrong how to find out what command utorrent is actually executing.

2.
rednoah wrote:Accidentally escaping arguments (filebot -rename "C:\files\" --action test)
If you want to use command-line tools, then you at least need to learn how to use (as opposed to program) command-line tools. Please read Cmdline and Argument Passing.

3.
Funnily enough, thanks to --log-file amc.log you don't need any of that because FileBot has been keeping a log all along. Reading the first line of the console output will give you a hint where to find it on your particular platform:

Code: Select all

Locking C:\Users\Russ\AppData\Roaming\FileBot\logs\amc.log
:idea: Please read the FAQ and How to Request Help.

MrTee001
Posts: 2
Joined: 06 Nov 2016, 04:08

Re: Q&A for n00bs

Post by MrTee001 » 06 Nov 2016, 05:05

PLEASE HELP!!!

Cant read any more lol. Still have no luck installing filebot on my qnap ts 251. So i ssh in with putty and then am getting stuck. I can log in fine but unable to proceed further. every version of command i run to try install doesnt work. Does anyone know which version i need to install ? Also how. I am very bad with linux. All help appreciated. I have optware, entware and java installed.

Thanks in advance

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

Re: Q&A for n00bs

Post by rednoah » 06 Nov 2016, 06:30

If you're so new to the command-line that you can't even download and extract archives, then I humbly suggest that you stick the the FileBot GUI because the filebot command-line tool requires basic command-line skills. ;)

However, getting started is as easy as this:

Code: Select all

wget -O FileBot.zip https://app.filebot.net/download.php?type=portable
unzip FileBot.zip
./filebot.sh -version
You may want to link filebot.sh into the $PATH afterwards.
:idea: Please read the FAQ and How to Request Help.

MrTee001
Posts: 2
Joined: 06 Nov 2016, 04:08

Re: Q&A for n00bs

Post by MrTee001 » 07 Nov 2016, 04:09

So this happened lol.

Code: Select all

[~] # wget -O FileBot.zip https://app.filebot.net/download.php?type=portable
--2016-11-06 23:08:15--  https://app.filebot.net/download.php?type=portable
Resolving app.filebot.net (app.filebot.net)... 104.27.153.61, 104.27.152.61, 2400:cb00:2048:1::681b:993d, ...
Connecting to app.filebot.net (app.filebot.net)|104.27.153.61|:443... connected.
ERROR: cannot verify app.filebot.net's certificate, issued by ‘/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO ECC Domain Validation Secure Server CA 2’:
  Unable to locally verify the issuer's authority.
To connect to app.filebot.net insecurely, use `--no-check-certificate'.
[~] # unzip FileBot.zip

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

Re: Q&A for n00bs

Post by rednoah » 07 Nov 2016, 06:13

Code: Select all

To connect to app.filebot.net insecurely, use `--no-check-certificate'.
So have you tried --no-check-certificate yet?
:idea: Please read the FAQ and How to Request Help.

saitoh183
Posts: 112
Joined: 02 Oct 2012, 16:59

Re: Q&A for n00bs

Post by saitoh183 » 10 Nov 2016, 19:01

Quick question about this filter: 'age < 7 || !model.any{ it.age < 7 }'

What does this portion !model.any{ it.age < 7 } tell filebot to do. I have searched the forum to try to understand but i didnt find anything.

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

Re: Q&A for n00bs

Post by rednoah » 10 Nov 2016, 19:13

rednoah wrote:only include episode data of recently aired episodes if there are any recently aired episodes, but otherwise default to accepting any episode data.

Code: Select all

--filter "age < 7 || !model.any{ it.age < 7 }"
@see viewtopic.php?f=3&t=2127


{age} is the age of the episode you're including or excluding. {model.age} is a list of all age values for all episodes in the current context. It's easy if you open the Format Editor on some real data and then just play with it for a few minutes.

model.any{ it.age < 7 } ... out of all the episodes being considered, is there any single episode that was aired within the last 7 days, yes or no?
:idea: Please read the FAQ and How to Request Help.

Manu
Posts: 5
Joined: 15 Nov 2016, 22:08

AMC Illegal usage: no input

Post by Manu » 15 Nov 2016, 22:17

Hi,

I've been using Filebot and AMC with qbittorrent without a problem since march. I have no idea what has gone wrong, but it hasn't worked for two weeks now.

Here's what I have in qbittorrent
filebot -script fn:amc --output "L:/SARJAT" --action duplicate --conflict skip -non-strict --log-file amc.log --def excludeList=amc.excludes unsorted=y music=y artwork=y "ut_dir=%F" "ut_kind=multi" "ut_title=%N" "ut_label=%L" --def movieFormat="J:/{ny}/{fn}"
And here's what the .log file says
Run script [fn:amc] at [Wed Nov 16 00:05:10 EET 2016]
Parameter: excludeList = amc.excludes
Parameter: unsorted = y
Parameter: music = y
Parameter: artwork = y
Parameter: ut_dir = %F
Parameter: ut_kind = multi
Parameter: ut_title = %N
Parameter: ut_label = %L
Parameter: movieFormat = J:/{ny}/{fn}
Bad ut_dir value: %F
Bad ut_title value: %N
Bad ut_label value: %L
Illegal usage: no input
Failure (°_°)
There could be a mistake in the qbittorrent part, I rewrote it after AMC stopped working.

also in the qbittorrent my temp folder is: L:\temp
and finished download folder is: L:\_SORT

I investigated and concluded that AMC doesn't get the labels from qbittorrent, which is the reason everything is broken. I have no idea why tho.

I changed the command to something that is a bit closer that I had before.
filebot -script fn:amc --output "L:/SARJAT" --action duplicate --conflict skip -non-strict --log-file amc.log --def excludeList=amc.excludes unsorted=y music=y artwork=y "ut_dir=%F" "ut_kind=multi" "ut_title=%N" "ut_label=%L" --def movieFormat="J:/_Elokuvat/{n} ({y})/{fn}" --def seriesFormat="L:/SARJAT/{n}/{'Season '+s}/{fn}"
Please help me, after using the AMC for so long and it now being broken is driving me suicidal.

From Finland with Love,
Manu

EDIT: Got it working by reinstalling qbittorrent again.

dfur
Posts: 2
Joined: 25 Mar 2017, 07:25

Re: Q&A for n00bs

Post by dfur » 25 Mar 2017, 08:31

This may well be a n00b problem but it took me ages to pin down where the problem was. I couldn't get the AMC script working when I added the default format expression for TV shows (copied from here). I eventually narrowed the problem down to one character in this part of the expression

Code: Select all

t.replaceAll(/[`´‘’ʻ]/, /'/)
The first character in the regex is a "backtick" or more correctly a "grave accent" and it was causing my script to fail, or at least pause and display a > prompt. If I removed that one character or escaped it with a backslash, as below, the script worked perfectly

Code: Select all

[\`´‘’ʻ]
I am curious to know why this problem might have occured. I am v new to groovy, but I recall reading that in slashy strings, the only character that needed to be escaped was the forward slash. What could be going wrong here?

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

Re: Q&A for n00bs

Post by rednoah » 25 Mar 2017, 08:35

` has special meaning in cmd and bash:
rednoah wrote:Use the @file syntax for reading cmdline args from text files so you don't have to worry about quoting and escaping arguments
Groovy is your friend. CMD is not.
:idea: Please read the FAQ and How to Request Help.

dfur
Posts: 2
Joined: 25 Mar 2017, 07:25

Re: Q&A for n00bs

Post by dfur » 26 Mar 2017, 04:26

Wow! :o I've just read up on backticks and command substution in Bash. That's quite a powerful little character.

For the record, any command between a pair of backticks will be run first and the output used as part of the main command. A single backtick causes Bash to show a prompt and wait for a command. Entering another backtick returns control to the original command. In modern shells, $(some command) does the same as, and is preferred to `some command`

So my interpretation is that using the unescaped backtick in an expression it is ok if the Groovy script is run by uTorrent, but definitely not if its run in Bash or CMD. I'll look into your suggested solution of reading arguments from a text file.

Thank you rednoah

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests