Move files from CLI after rename ?

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
boboch
Posts: 5
Joined: 29 Dec 2016, 09:49

Move files from CLI after rename ?

Post by boboch »

Hi all,

I just discovered filebot (shame on me, i know) rename part works really great !

I wonder if there is a way to do more little tricks with CLI part of the program on my debian server.

Architecture:
/mnt/volume1/telechargements => folder to download files
/mnt/volume1/videos/series => folder to TV Show files
  • -/mnt/volume1/videos/series/Dexter/Saison 1
    -/mnt/volume1/videos/series/The Walking Dead/Saison 1
    -/mnt/volume1/videos/series/StartUp/Saison 1
    - etc...
/mnt/volume1/videos/films => folder to movies files

What i would like to do:

1-After rename by filebot, if file is a Movie then move it to movies folder from download folder
2- If TV show then move it to TV show folder while keeping my current tree and create it if doesn't exist, e.g:
I already have "The Walking Dead", and sub directory "Saison 1", if filebot rename a new episode from Season 2 then create sub directory "Saison 2" and move file into it.

Is there a way to do that or is too little tricky for CLI ?

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

Re: Move files from CLI after rename ?

Post by rednoah »

Did you read FAQ #1 yet? It's just a matter of passing in the --format you want.

e.g.

Code: Select all

--output "/mnt/volume1/videos" --format "{plex}"
:idea: Please read the FAQ and How to Request Help.
boboch
Posts: 5
Joined: 29 Dec 2016, 09:49

Re: Move files from CLI after rename ?

Post by boboch »

Hi rednoah,

I read the FAQ, i only use CLI, but i don't really understand where i can put this different argument.

e.g. with Chuck S01E05.mkv in "telechargements" folder

Code: Select all

filebot -rename -r -non-strict /mnt/volume1/telechargements/ --output "/mnt/volume1/videos" --format "{plex}" --lang fr
This one, make the job perfectly, but create new folder and subfolder (TV Show/Chuck/Season 01/), but i already have it (videos/series/Chuck/Saison 1) and don't want filebot make a new one if one already exist.

I think i should use naming scheme, but don't understand really how it works :oops:

Is there any space where i can found some example of complete CLI ?

Thanks :)

PS: HAPPY NEW YEAR (from France) ! :)
User avatar
rednoah
The Source
Posts: 23954
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Move files from CLI after rename ?

Post by rednoah »

Yes, you should use a custom naming scheme.

Use the GUI to prototype your custom naming scheme:
Image

Reusing bits and pieces of the {plex} binding might be helpful:
viewtopic.php?f=5&t=4116
:idea: Please read the FAQ and How to Request Help.
boboch
Posts: 5
Joined: 29 Dec 2016, 09:49

Re: Move files from CLI after rename ?

Post by boboch »

Thanks for answer.

I found the solution, i use the amc script:

Code: Select all

filebot -script fn:amc --output "/mnt/volume1/videos" --action move -non-strict "/mnt/volume1/telechargements/" --def "seriesFormat=/mnt/volume1/videos/series/{n}/{'Saison '+s}/{n} - {s00e00} - {t}" "movieFormat=/mnt/volume1/videos/films/{n} - ({y})" "animeFormat=/mnt/volume1/videos/animations/{n} - ({y})" --lang fr
I made a incron task for new files into "/mnt/volume1/telechargements/" which call a little bash script (2 lines) for chown new files and execute the above filebot CLI, my first chown command is execute when a new files appear into the watched folder, the filebot CLI, does not BUT when i execute manually my script, everything works fine.

Any recommendations ?
User avatar
rednoah
The Source
Posts: 23954
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Move files from CLI after rename ?

Post by rednoah »

1.
rednoah wrote:Note that if you call this script in intervals every hour or every day you must set --def excludeList or you will get banned.
--def excludeList is absolutely mandatory if you're doing what you're doing!


2.
You can use the --def exec option to chown newly processed files or folders.
:idea: Please read the FAQ and How to Request Help.
boboch
Posts: 5
Joined: 29 Dec 2016, 09:49

Re: Move files from CLI after rename ?

Post by boboch »

1- yes, i add the following --def excludeList=amc.txt

2- I try different way to be able to run my script with an incron task, but the filebot command does not execute...

Here my incron task:

Code: Select all

/mnt/volume1/telechargements IN_CLOSE_WRITE /opt/Script/chown_rename.sh
Here my script with no chown command but chown command inside filebot CL with "--def exec=" :

Code: Select all

#!/bin/bash
echo $PATH
/usr/bin/filebot -script fn:amc --output "/mnt/volume1/videos" --action move -non-strict "/mnt/volume1/telechargements/" --def "seriesFormat=/mnt/volume1/videos/series/{n}/{'Saison '+s}/{n} - {s00e00} - {t}" "movieFormat=/mnt/volume1/videos/films/{n} - ({y})" "animeFormat=/mnt/volume1/videos/animations/{n} - ({y})" --lang fr --def excludeList=amc.txt --def exec="chown qwrty:qwrty '{file}'"
Nothing is happening, expect syslog entry for both case.

Without:

Code: Select all

#!/bin/bash
echo $PATH
chown -R /mnt/volume1/telechargement
/usr/bin/filebot -script fn:amc --output "/mnt/volume1/videos" --action move -non-strict "/mnt/volume1/telechargements/" --def "seriesFormat=/mnt/volume1/videos/series/{n}/{'Saison '+s}/{n} - {s00e00} - {t}" "movieFormat=/mnt/volume1/videos/films/{n} - ({y})" "animeFormat=/mnt/volume1/videos/animations/{n} - ({y})" --lang fr --def excludeList=amc.txt
Only chown is execute.

Syslog entry:

Code: Select all

Jan  2 23:18:12 LINOLOGY incrond[21804]: (root) CMD (/opt/Script/chown_rename.sh)
When i execute manually the script everything works fine...
User avatar
rednoah
The Source
Posts: 23954
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Move files from CLI after rename ?

Post by rednoah »

Did you confirm that FileBot is even called in the first place?
viewtopic.php?f=4&t=3067

PS: --log-file amc.log is mandatory as well (unless you take care of IO redirection and synchronisation yourself).
:idea: Please read the FAQ and How to Request Help.
boboch
Posts: 5
Joined: 29 Dec 2016, 09:49

Re: Move files from CLI after rename ?

Post by boboch »

Ok, so after debug, i feel like an idiot...

The output said me: "$HOME must be define"

So i add the following line to my script: export HOME=/root

Everything works good now !

Many thanks rednoah.
Post Reply