Command line OSX

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
dewy
Posts: 9
Joined: 20 Jan 2012, 23:24

Command line OSX

Post by dewy »

Hi there, firstly thanks for developing such an amazing piece of software. However I'm having trouble running scripts or executing the program from the command line. Could you please provide a brief instruction on how to install filebot for OSX so I can execute it from the terminal/run a script. I want to automate moving from my downloads folder into /Volumes/TV\ Shows/'show name'/'season #'/...
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

Well, since an app bundle is not an installer the "filebot" command can't be setup automatically. But there is an install script in FileBot.app/MacOS/bin

Run FileBot.app/MacOS/bin/install.sh to link "filebot" into /bin
:idea: Please read the FAQ and How to Request Help.
dewy
Posts: 9
Joined: 20 Jan 2012, 23:24

Re: Command line OSX

Post by dewy »

Thanks, however the directory in my .app (downloaded from the SF page a few hours ago

Filebot.app/Contents/MacOS/install.sh

Before I was trying to run things as Finebot.app -script =P
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

Yep that folder then. :P

That would be cool but Apple says app bundles must be GUI apps so no console. But I did ready in newer OSXs you can do something like "start Filebot.app -arguments <appl.args>" but that's kinda crap. Better just install the command.
:idea: Please read the FAQ and How to Request Help.
dewy
Posts: 9
Joined: 20 Jan 2012, 23:24

Re: Command line OSX

Post by dewy »

Any possible assistance with this:
192-168-1-6:~ dewy$ filebot -script "~/Downloads/sort.groovy"
FileNotFoundException: ~/Downloads/sort.groovy
java.io.FileNotFoundException: ~/Downloads/sort.groovy
at net.sourceforge.filebot.cli.ArgumentBean.getScriptLocation(Unknown Source)
at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)
at net.sourceforge.filebot.Main.main(Unknown Source)
Failure (?_?)
Does a script have to be loaded from the HTTP?
dewy
Posts: 9
Joined: 20 Jan 2012, 23:24

Re: Command line OSX

Post by dewy »

Basically at the moment I have uTorrent set up using RSS to download to "/Volumes/Drobo/Downloads/" automatically.

So I want a script to watch this directory, then rename and file into
"/Volumes/Drobo/TV Shows/[showname]/..."

So I know I want my output format to be:

Code: Select all

/Volumes/Drobo/TV Shows/{n}/Season {s}/{n} - {s00e00} - {t}
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

Be careful about the ~/ you put it into "" so your shell won't resolve it to /home/me/. Use absolute paths for simplicity.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

Check out the housekeeping.groovy script. Modify to the way you need it and it should work fine. Better have utorrent move completed/seeded downloads into a separate "watched" folder so u don't get conflicts with open file handles / missing files / etc
:idea: Please read the FAQ and How to Request Help.
dewy
Posts: 9
Joined: 20 Jan 2012, 23:24

Re: Command line OSX

Post by dewy »

Thanks.

So far I have the current terminal command working:

Code: Select all

filebot -rename /Volumes/Drobo/Downloads/ --format "/Volumes/Drobo/TV Shows/{n}/Season {s}/{n} - {s00e00} - {t}" --db thetvdb
Is there a way I can automate this to watch the directory and not have to open terminal?
dewy
Posts: 9
Joined: 20 Jan 2012, 23:24

Re: Command line OSX

Post by dewy »

Housekeeping script looks good. Any idea how to automate it?

Edit: By Automate it I mean - can we have it run without a terminal window?
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

It's just a command. MacOS should have faculties to just launch stuff in background on startup. Or you can have utorrent initiate a rename after a completed download.
:idea: Please read the FAQ and How to Request Help.
dewy
Posts: 9
Joined: 20 Jan 2012, 23:24

Re: Command line OSX

Post by dewy »

Running my command of

Code: Select all

filebot -rename /Volumes/Drobo/Downloads/* --format "/Volumes/Drobo/TV Shows/{n}/Season {s}/{n} - {s00e00} - {t}" --db thetvdbp
I now get the following error:
[quote]192-168-1-6:Downloads dewy$ filebot -rename /Volumes/Drobo/Downloads/* --format "/Volumes/Drobo/TV Shows/{n}/Season {s}/{n} - {s00e00} - {t}" --db thetvdb
Rename episodes using [TheTVDB]
Exception: Unable to auto-select query: [How to Make It in America, Hustle]
Failure (?_?)
192-168-1-6:Downloads dewy$ [quote]

It works without issue when there is only one file in the folder. But when more than one file exists I have no luck.
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

Not because it's one file but because it's multiple shows from the same folder. Cmdline is strict by default, so you won't mess up your files.

Enable fuzzy logic via -non-strict and it'll "most probably" get things right the way u want it.
:idea: Please read the FAQ and How to Request Help.
dukenbat
Posts: 3
Joined: 10 Jan 2012, 18:09

Re: Command line OSX

Post by dukenbat »

I had some trouble getting the command line Filebot application to run. Thought I would share my solution.
I have never worked with Java before, so be gentle if this is all wrong.
I'm using a stock install of OSX Lion with all updates run.

1. ran install.sh from inside the Filebot.app

$ filebot -script "~/Downloads/sort.groovy"

produces this error
ClassNotFoundException: java.nio.file.FileVisitor
java.lang.ClassNotFoundException: java.nio.file.FileVisitor

Missing a class?

$java -version
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)

Java 7 needs to be installed, you can find it and instruction here...
http://code.google.com/p/openjdk-osx-bu ... MACOSXPORT

It is easy, just a dmg containing one package, then run the following command:

$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home

Works fine now.

Hope this helps someone.
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

Java 7 on OSX?? Awesome! Just had people complaining that it's really difficult to install. Thanks for sharing!

Actually scripting should work with Java 6 as well but something got messed up in 2.4, my fault sry :P
:idea: Please read the FAQ and How to Request Help.
dewy
Posts: 9
Joined: 20 Jan 2012, 23:24

Re: Command line OSX

Post by dewy »

Okay guys, I have created something that works well. Using Automator I created a "Folder Action" on my downloads directory. So the moment my torrent application is finished with the file it dumps it into this directory. The Folder Action watches for any new items in this folder and immediately runs the shell command:

Code: Select all

 filebot -rename /Volumes/Drobo/Downloads/* --format "/Volumes/Drobo/TV Shows/{n}/Season {s}/{n} - {s00e00} - {t}" --db thetvdb -non-strict
Image

Hopefully this helps give people an alternative to the confusing scripting method.

Ps. Thanks for the fuzzy logic argument.
lyonss3
Posts: 6
Joined: 20 Jan 2012, 19:50

Re: Command line OSX

Post by lyonss3 »

dewy wrote:Okay guys, I have created something that works well. Using Automator I created a "Folder Action" on my downloads directory. So the moment my torrent application is finished with the file it dumps it into this directory. The Folder Action watches for any new items in this folder and immediately runs the shell command:

Code: Select all

 filebot -rename /Volumes/Drobo/Downloads/* --format "/Volumes/Drobo/TV Shows/{n}/Season {s}/{n} - {s00e00} - {t}" --db thetvdb -non-strict
that is beautiful, thank you. now do i just save the folder action anywhere and from now on when a file is added it will automatically run the command?
marceld
Posts: 1
Joined: 02 Feb 2012, 18:15

command not found

Post by marceld »

I've installed filebot.sh but keep getting: command not found, what could I be doing wrong?
thequestion
Posts: 8
Joined: 18 Dec 2011, 17:52

Re: Command line OSX

Post by thequestion »

did you chmod 755 filebot.sh? it has to be executable
stewmo
Posts: 5
Joined: 11 Apr 2013, 15:39

Re: Command line OSX

Post by stewmo »

Hi...

I'm really new (as in never done before) to anything CLI, but I want to install filebot.sh, so I can enter script to automate moving and re-naming files. Whenever I try to post in anything on Terminal (the OS X CLI app) I get the following message:


-bash: filebot: command not found


I want to be able to automate naming files, then moving them into another folder (I have an app called Hazel which handles everything but the re-naming process).

Any help from anyone who knows what's up would be greatly appreciated.

Really like what you're doing here, this software is amazing.
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

Replace "filebot" with /Applications/path/to/app/FileBot.app/MacOS/filebot.sh
:idea: Please read the FAQ and How to Request Help.
stewmo
Posts: 5
Joined: 11 Apr 2013, 15:39

Re: Command line OSX

Post by stewmo »

And then I just type in the rest of the code I want?
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

start with filebot -version first anyway, and then once you confirmed it works try more complex things
:idea: Please read the FAQ and How to Request Help.
stewmo
Posts: 5
Joined: 11 Apr 2013, 15:39

Re: Command line OSX

Post by stewmo »

This what I have (I think it is the way I'm supposed to). Does this script make sense?

/Applications/imac/Downloads/Filebot.app/MacOS/filebot.sh -rename "$1" --format {n} S{s}E{e} --db thetvdb
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

Just try. Add --action test just in case.
:idea: Please read the FAQ and How to Request Help.
stewmo
Posts: 5
Joined: 11 Apr 2013, 15:39

Re: Command line OSX

Post by stewmo »

I'm using the app Automator, (which creates Workflows for you to automate tasks), and whenever I try to run the following shell script:


/Applications/imac/Downloads/Filebot.app/MacOS/filebot.sh -rename "$1" --format {n} S{s}E{e} --db thetvdb --action test -non-strict

I get the error:

-: /Applications/imac/Downloads/Filebot.app/MacOS/filebot.sh: No such file or directory.

Am I doing something wrong? It looks to be correct (I think, I'm a bit of a noob to this sort of stuff).
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

And you never ever even tried to just open that path? It clearly says "No such file or directory" => PATH DOES NOT EXIST.

Maybe?
/path/to/FileBot.app/Contents/MacOS/filebot

But ignore that, figure it out yourself, open the .app folder, look for an executable called filebot, open the console and play with it. It's not rocket science.

You're on Mac, you see everything, I'm on Windows, I have no idea, yet I these things are so obvious... Learn how to use the console. Just ls, cd etc, execute programs. VERY BASIC.
:idea: Please read the FAQ and How to Request Help.
stewmo
Posts: 5
Joined: 11 Apr 2013, 15:39

Re: Command line OSX

Post by stewmo »

I did finally get it working after much experimentation.

It turns out I needed to use a sudo command to install the contents of the bundle. Now I can access it. I do appreciate all your help, even if I pissed you off
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

Level +1, experimenting is how you do these things, now you got basic commandline skills. ;)
:idea: Please read the FAQ and How to Request Help.
User avatar
fry
Posts: 6
Joined: 02 Aug 2014, 16:43

Re: Command line OSX

Post by fry »

When I run FileBot I get:

Code: Select all

Exception in thread "main" java.lang.UnsupportedClassVersionError: net/filebot/Main : Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247
For the record, I run Java 7 Update 65 on my machine.

Any ideas?

PS: I'm on 10.10.
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

For the record, you are running Java 6.

This might help: http://www.filebot.net/forums/viewtopic ... 652#p10683
:idea: Please read the FAQ and How to Request Help.
User avatar
fry
Posts: 6
Joined: 02 Aug 2014, 16:43

Re: Command line OSX

Post by fry »

That's so strange… my shell indeed outputs:

Code: Select all

java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)
… despite my control panel telling me:

Image

And the latest build from Oracle won't install no matter what they say here. I guess I just have to be patient and wait until the release something that works.
srkinard
Donor
Posts: 19
Joined: 08 Feb 2014, 03:38

Re: Command line OSX

Post by srkinard »

Only took 2 commands to switch Java on my 10.10 Yosemite dev box:

BEFORE:

Code: Select all

->$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)
COMMANDS:

Code: Select all

sudo rm /usr/bin/java
sudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin
AFTER:

Code: Select all

->$ java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
Hope this helps.
User avatar
fry
Posts: 6
Joined: 02 Aug 2014, 16:43

Re: Command line OSX

Post by fry »

A good fix. Thanks.
panda78
Posts: 38
Joined: 22 Jan 2016, 18:45

Re: Command line OSX

Post by panda78 »

sorry ,
i'm trying to learn how to work with CLI using filebot.app in osx because my synology cant run filebot7filebot node cause low ram and cpu :(
I'm searching for install.sh but in my filebot.app content it isn't

can you help me ?

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

Re: Command line OSX

Post by rednoah »

This thread is outdated.

Use brew cask:
viewtopic.php?f=4&t=2049
:idea: Please read the FAQ and How to Request Help.
panda78
Posts: 38
Joined: 22 Jan 2016, 18:45

Re: Command line OSX

Post by panda78 »

rednoah wrote:This thread is outdated.

Use brew cask:
viewtopic.php?f=4&t=2049
i have just pay for filebot on mac app store :(
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

Your contribution is much appreciated. Make sure to give me a 5-star rating. Thank you!
:idea: Please read the FAQ and How to Request Help.
togo
Posts: 1
Joined: 09 Apr 2017, 18:52

Re: Command line OSX

Post by togo »

Hi there, I'm using FileBot a while with GUI and today I wanted to test FileBot with CLI, but I'm getting
"-bash: filebot: command not found"

I have bought FileBot on Mac AppStore and I don't have "filebot.sh" in ../FileBot.app/Contents/MacOS

How can I use FileBot with CLI?

Thank you...
User avatar
rednoah
The Source
Posts: 24661
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Command line OSX

Post by rednoah »

:idea: Apple doesn't allow command-line tools in Mac App Store bundles.

You can install the filebot command-line tools via brew:
viewtopic.php?t=2049
:idea: Please read the FAQ and How to Request Help.
Post Reply