Use case: Monitor local shared folder and import contents.

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
yay101
Posts: 6
Joined: 18 Dec 2011, 13:02

Use case: Monitor local shared folder and import contents.

Post by yay101 » 18 Dec 2011, 13:18

I have a linux mint server hosting ftp, subsonic and samba sharing. Among its shared folders over samba is a folder called "Import" in the location /media/storage/files/import.

I would like to have this file server grab the files such as "media/storage/files/import/modern.family.s02e07.avi" and rename based on my set style and move the file to a scripted location, for instance "/media/storage/files/tv/Modern Family/Season 2/".

How would i achieve this?

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

Re: Use case: Monitor local shared folder and import conten

Post by rednoah » 18 Dec 2011, 13:34

Just that folder?

Code: Select all

filebot -rename "/media/storage/files/import/" --format "/media/storage/files/tv/{n}{'/Season '+s}/{episode}"
To organize an entire hierarchy do the same via scripting:

Code: Select all

filebot -script "http://filebot.sourceforge.net/data/shell/renall.groovy" "/media/storage/files/import/" --format "/media/storage/files/tv/{n}{'/Season '+s}/{episode}"
:idea: Please read the FAQ and How to Request Help.

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

Re: Use case: Monitor local shared folder and import conten

Post by rednoah » 18 Dec 2011, 14:09

This is an example for folder watching, it'll run the batch processing after there have not been any changes to the folder (files created, files modified, ...) for a given amount of time. This is for files only, because for subfolders i only get create events but if files are modified within that new folder than those changes don't get tracked, meaning batch processing might kick off 10min after the folder has been created but before copying all files has completed.

Download:
http://filebot.sourceforge.net/data/she ... her.groovy
:idea: Please read the FAQ and How to Request Help.

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

Re: Use case: Monitor local shared folder and import conten

Post by rednoah » 19 Dec 2011, 11:43

Added another example groovy script on how to keep running as daemon and continuously keep checking for new files to rename:

Code: Select all

filebot -script "http://filebot.sourceforge.net/data/shell/housekeeping.groovy" <completed downloads folder>
Source:
http://filebot.sourceforge.net/data/she ... ing.groovy
:idea: Please read the FAQ and How to Request Help.

Synergie
Posts: 2
Joined: 07 Feb 2012, 12:22

Re: Use case: Monitor local shared folder and import conten

Post by Synergie » 07 Feb 2012, 13:01

Hi all,
I love Filebot and would love to keep filebot running in the background and monitor a folder as a file is added, I want filebot to it scan and rename the file, although I really have no idea how to implement the script mentioned here.

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

Re: Use case: Monitor local shared folder and import conten

Post by rednoah » 07 Feb 2012, 13:09

Check the other thread for shared scripts. The watcher.groovy should do what you need.
:idea: Please read the FAQ and How to Request Help.

Synergie
Posts: 2
Joined: 07 Feb 2012, 12:22

Re: Use case: Monitor local shared folder and import conten

Post by Synergie » 07 Feb 2012, 14:28

EDIT: Nevermind, I found the manual :D.

sanjonny
Posts: 70
Joined: 08 Feb 2012, 02:55

Re: Use case: Monitor local shared folder and import conten

Post by sanjonny » 27 Feb 2012, 23:42

I hope this doesnt sound too stupid, but i think this might do exactly something I have been looking to do, which is go thru a folder of mixed files and be able to automatically rename them.

I have mixed files because lots are coming from the tivo, so wondering if this command stated or modifications of it will help do what I want, and wondering what happens with errors.

Code: Select all

filebot -rename "/media/storage/files/import/" --format "/media/storage/files/tv/{n}{'/Season '+s}/{episode}"
Also, for windows machines, do I change it to the forward slashes to backslashes or does filebot account for that. In other words should this be:

Code: Select all

filebot -rename "\media\storage\files\import\" --format "\media\storage\files\tv\{n}{'\Season '+s}\{episode}"
For example, today I have the following that the tivo has downloaded and then has been processed and commercials cut and such and the files are sitting in the folder waiting to be renamed:

L.A. Confidential
The Maltese Falcon

Grimm - Last Grimm Standing
Heavy Metal - P-38 Lightning strikes
Ocean of Fear Worst shark attack ever - The sinking of the Indianapolis
Patton 360 - Leading the Charge
The League - St. Pete
The League - Thanksgiving


I am assuming it is not smart enough to segregate the movies from the tv shows (unless now thinking about it, I guess it could try to find a tvshow and if it fails, try to find a movie name that matches, that would be cool and might work)so I could break them up and put the movies in one folder with one set of commands and the tvshows in another, but I happen to know that Heavy Metal will not work correctly because there is not a good match for it in any of the tvdbs (it sometimes finds heavy metal task force automatically, but that is wrong) and ocean of fear is a one time episode. Patton, Grimm and the League all are easily identified.

So what happens if the file bot command cannot find a match? Or what if it find the wrong match? I am kinda spitballing here because I haven't tried much of the command line but I would assume if it didn't find it, it would fail, but maybe it allows yes/know or approve/disprove or something, since you cannot see it like in the gui?

sanjonny
Posts: 70
Joined: 08 Feb 2012, 02:55

Re: Use case: Monitor local shared folder and import conten

Post by sanjonny » 28 Feb 2012, 01:39

Also, after I posted this, I went onto tvdb and input all the heavy metal episodes, I don't know how long they take to show up in filebot, but i know it usually takes about a day, I have been meaning to do this and had some time today, but assuming they would not work, what would happen?

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

Re: Use case: Monitor local shared folder and import conten

Post by rednoah » 28 Feb 2012, 02:30

sanjonny wrote:Also, after I posted this, I went onto tvdb and input all the heavy metal episodes, I don't know how long they take to show up in filebot, but i know it usually takes about a day, I have been meaning to do this and had some time today, but assuming they would not work, what would happen?
TheTVDB encourages heavy caching, so it's set to 1 month by default. Easy solution is running

Code: Select all

filebot -clear
but note that this will clear cache and GUI preferences.
:idea: Please read the FAQ and How to Request Help.

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

Re: Use case: Monitor local shared folder and import conten

Post by rednoah » 28 Feb 2012, 03:44

sanjonny wrote: Also, for windows machines, do I change it to the forward slashes to backslashes or does filebot account for that.
Don't worry about / vs \. Java takes care of that on any level. Even on Windows I always use / because using \ just feels wrong. :P
sanjonny wrote: For example, today I have the following that the tivo has downloaded and then has been processed and commercials cut and such and the files are sitting in the folder waiting to be renamed:

L.A. Confidential
The Maltese Falcon

Grimm - Last Grimm Standing
Heavy Metal - P-38 Lightning strikes
Ocean of Fear Worst shark attack ever - The sinking of the Indianapolis
Patton 360 - Leading the Charge
The League - St. Pete
The League - Thanksgiving


I am assuming it is not smart enough to segregate the movies from the tv shows (unless now thinking about it, I guess it could try to find a tvshow and if it fails, try to find a movie name that matches, that would be cool and might work)so I could break them up and put the movies in one folder with one set of commands and the tvshows in another.
By default (not forcing a --db) FileBot will auto-detect whether to run movie-mode or series-mode. Heuristics for a series are SxE/Date patterns and generic patterns that are common to most files.

But I guess you're talking no SxE patterns with 1 file per folder. So that is a different situation. But with scripting you can build a specialized solution for this.

If you don't mind some FileBot/Groovy scripting, you should be able to fully-automate everything. Not gonna be much code, but will need time testing and fine-tuning. A lot of things are already there, just need to put it together the way you need it.

String detectSeriesName(File|File[] one or more episodes)
Movie detectMovie(File movie, boolean strict)
@see http://filebot.svn.sourceforge.net/view ... iew=markup

There's also an old proof-of-concept (basic and crap, but it's kinda what you suggested):
@see http://filebot.sourceforge.net/scripts/rsam.groovy
sanjonny wrote: So what happens if the file bot command cannot find a match? Or what if it find the wrong match? I am kinda spitballing here because I haven't tried much of the command line but I would assume if it didn't find it, it would fail, but maybe it allows yes/know or approve/disprove or something, since you cannot see it like in the gui?
By default FileBot will never mess up your files, ever (if that happens it's a severe bug).

But in many cases the CLI refuses to match files, when the GUI seemingly does so without problem. In that case you can add -non-strict for a more "best guess" like approach. Most probably gonna work perfectly. But may not in certain circumstances, e.g. if online data doesn't match your files, FileBot may match to the "next best" but completely wrong tvshow/episode data.

But don't worry, FileBot does keep a history of all rename operations (GUI or CLI doesn't matter). You can revert any rename batch via Rename Panel > Rename Options > Open History
:idea: Please read the FAQ and How to Request Help.

sanjonny
Posts: 70
Joined: 08 Feb 2012, 02:55

Re: Use case: Monitor local shared folder and import conten

Post by sanjonny » 28 Feb 2012, 04:10

I don't know if I am reading this wrong or if you don't get what I am doing so just to check, I want the script to basically go to the folder with all those files in it (movies and tv shows mixed) and be able to rename them all. It doesn't have to move them or sort them, I have other programs that do that, the problem is the mix.

I am not hugely concerned with getting the movie and tvshow detection correct all at once for the same directory, though I can work on that, more what I am really focusing on is I have 4 different tv shows all in the import directory (or whatever) and want filebot to try to rename them either line by line or match series and then figure out episodes. So say above, I only have the bolded (tv shows) in a folder, I want the script to try and rename them all even though they are different shows. And what happens when the cli script hits the Ocean of fear show, which doesn't exist- does it just skip it or try to match it or does that stop the script cold. Again this is all curiosity, as I am not good at groovy stuff, but I can probably cludge my way thru it when I have some free time if it sounds possible. Or another thought is being able to put different shows all at once in the GUI and have it name them, like it does with the movies, even though they don't have season and episode tags. I know now that doesn't work in GUI mode for tv shows, but would that be possible. I also know that might be a problem on many levels and might slow the heck out of things too. It just would fit nicely for what I do since getting stuff from the TIvo is exactly what I have going on and I get a mix of stuff, that currently, I just drag and drop individual tvshows into the gui and rename them.

I love Filebot though, not trying to be negative or anything because it is the only program that effectively helps me with the problem of not having season and episode numbers in the filename, but the actual title matching that corrects for that, which is absolutely great and quick. All the other stuff is gravy and as usual, my curious mind means I will spend 2 hours trying to figure out how to automate something that I could do by hand in 5 minutes, but it is just the cool factor of getting it to work and all. I am older than the average bear in these forums likely and the last programming I did and understood all the commands was 20+ years ago, but I know just enough to be dangerous and believe me, if I had the time, I would learn the new languages in depth, especially java so I could help with projects like this. Maybe when I retire? In the interim, thanks for the help.

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

Re: Use case: Monitor local shared folder and import conten

Post by rednoah » 28 Feb 2012, 06:29

Now in strict mode it's restricted to one show per match set, but with -non-strict it generally works (there might be problems with that unknown tvshow though).

Same as GUI. Multiple shows at the same time is fully supported. Auto-detecting the show name from the filenames to get episode data might be the problem. If you have at least 5 episodes of one show, even without SxE, it should get picked up. Send me a list of filenames and I'll test that and see if there is a bug. The new beta might work better in regard to that.

Doesn't sound to complicated. Send me your folder/filename structure. If I have test data I can easily script that. Should be just a few lines as far as I understand the problem.
:idea: Please read the FAQ and How to Request Help.

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

Re: Use case: Monitor local shared folder and import conten

Post by rednoah » 02 Mar 2012, 08:04

Here's a script that should work for your tivo folder:
* every file is handled individually
* episode-vs-movie is auto-detected based on filename or osdb hash (may need some tweaking to exactly fit your needs)

Script:
http://filebot.sourceforge.net/scripts/sortivo.groovy

(requires r933 from http://sourceforge.net/projects/filebot ... ebot/HEAD/)
:idea: Please read the FAQ and How to Request Help.

sanjonny
Posts: 70
Joined: 08 Feb 2012, 02:55

Re: Use case: Monitor local shared folder and import conten

Post by sanjonny » 08 Mar 2012, 04:54

Thanks I'll try it out, have been really busy and not had time to work on anything but hopefully will tonight or tomorrow and get back to you.

Post Reply