Automated Media Center: --def exec option

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
Hematot
Posts: 17
Joined: 31 Mar 2012, 11:33

Automated Media Center: --def exec option

Post by Hematot »

I've been using the amc with uTorrent for renaming and fetching subtitles for some time now and it works like a charm!
Amc sorts my incoming media files depending on type (Movies/TVshows) and the TVshows are put into folders named after the show.
Nothing strange, just basic stuff for amc (isn't that nice :)).

As it happens, I now need to have an extra copy of my TV show episodes (on another drive).
So I added the new exec command to the amc call after the --def flag like this: "exec=E:/batfiles/tvixcopy.bat ""{file}"""
The called tvixcopy.bat file consist of one line only: "copy "%~f1" "E:\TVshows\%~nx1""
So far so good, also works just fine.

However, I would like to get a duplicate copy of TV shows only but not of Movies.
So to the questions:
1. Is there a smarter way of doing this? Searched the forums but didn't find anything...
2. If not; are there any other parameters (than the {file}) to send along? (For this purpose or others).

(I know that there's always the possibility to filter on the {file} parameter against my known TV/Movies location but when changing target locations I would have to edit the tvixcopy.bat as well.)

Cheers
/D
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Automated Media Center: --def exec option

Post by rednoah »

Well, you'll still have to check that somewhere. By the time it's running the execs it doesn't know anymore what's originally been a movie and what not.

The parameters work the same as the format. So you could do something like

Code: Select all

copy "{file =~ /Movies/ ? file : 'N:/invalid-path-that-makes-copy-fail'}" "X:/some/where"
:idea: Please read the FAQ and How to Request Help.
Hematot
Posts: 17
Joined: 31 Mar 2012, 11:33

Re: Automated Media Center: --def exec option

Post by Hematot »

Are you saying that it's possible to pass along all parameters from http://www.filebot.net/naming.html, section Binding Reference?

So if the uTorrent amc call included:
--def "exec=E:/batfiles/tvixcopy.bat ""{file}"" ""{n}"" ""{sxe}"" ""{t}"" "
my bat file would receive 4 parameters (file, series/movie name, season / episode numbers, episode title) ?
(I assume some sort off null value for n.a. values; like {sxe} for a Movie file?)

Where can I find info about the syntax in your example?
(file =~ /Movies/ ? file : 'N:/invalid-path-that-makes-copy-fail')
Is it groovy? I'll google it, but maybe you have some good suggestions?

PS
Am I right in assuming that your example was supposed to be used like this?:
--def "exec=copy "{file =~ /Movies/ ? file : 'N:/invalid-path-that-makes-copy-fail'}" "X:/some/where" "
DS

:? :D /D
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Automated Media Center: --def exec option

Post by rednoah »

Kinda, but of course all the episode/movie bindings will error out, always. You can only use file-based bindings {file} {fn} {ext} {folder} {vc} etc but not episode/movie-based bindings {n} {sxe} {year} etc

Yes, it's Groovy.

And make sure you cmdline-escape double-quotes properly.
:idea: Please read the FAQ and How to Request Help.
Hematot
Posts: 17
Joined: 31 Mar 2012, 11:33

Re: Automated Media Center: --def exec option

Post by Hematot »

Thanks rednoah,
time to start experimenting.
Yeah, double quoting... I'll do as always - trial and error. After a while it ususally gets right.

- Still confused, but on a higher level!
Hausner
Posts: 8
Joined: 03 Apr 2013, 04:06

Re: Automated Media Center: --def exec option

Post by Hausner »

@Hematot: Have you found the answer yet, cause I have a similar problem I can't seem to get past.

I'm trying to pass {file} {fn} {ext} {folder} to a batch script, so that I can re-encode with Handbrake, but I can't get those damn quotes right, so that Handbrake can understand the output filename. eg. --def exec=x:\batfile.bat "{file}" "{fn}" "{ext}" "{folder}" becomes eg. c:\tmp\"this is the folder name"\"this is the filename".mkv if there are spaces in file/folder name - and that's no good :(
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Automated Media Center: --def exec option

Post by rednoah »

Try this:

Code: Select all

--def "exec=cmd /c x:\batfile.bat \"{file}\" \"{fn}\" \"{ext}\" \"{folder}\""
The amc script does log each command that is executed so you can easily try it yourself and see where you messed up the quotes.
:idea: Please read the FAQ and How to Request Help.
Hausner
Posts: 8
Joined: 03 Apr 2013, 04:06

Re: Automated Media Center: --def exec option

Post by Hausner »

Yes, I got that working, but maybe I didn't explain my problem properly.

--def "exec=cmd /c x:\batfile.bat \"{file}\" \"{fn}\" \"{ext}\" \"{folder}\"" will execute the batfile with 4 variables.

The problem is that, when the file runs, the variables are still in "" eg. %2 = "Some filename" and %4 = "Some filepath".

Handbrake uses an -o (output) option it's filename to write to. But if I do like eg. "c:\tmp\%4\%2.ext", the result will be: "c:\tmp\"Some filepath"\"Some filename".mkv". As you can see that will not work, so I somehow have to to remove those " from the variables before pushing it in as a filepath/ -name.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Automated Media Center: --def exec option

Post by rednoah »

Well, that's really an issue with your bat script. That always sucks. :D

Lets do more Groovy and less batch scripting. So you mean you want the filename? {file} will evaluate to the absolute path. You seem to want {file.name}, only the filename (i.e. filename with extension).
:idea: Please read the FAQ and How to Request Help.
Hausner
Posts: 8
Joined: 03 Apr 2013, 04:06

Re: Automated Media Center: --def exec option

Post by Hausner »

Well basicly I just want a complete output-path. eg. c:\movies\Moviename (yyyy)\Moviename (yyyy).mkv, so I can pass that as an output string to Handbrake. Same place/path as FileBot copies the files to.

The thing is, I want to convert ISO files to mkv files, which my TV can play.

I actually got it working now with a little batch scripting (search/replace). I'm def not into groovy scripting lol
Hematot
Posts: 17
Joined: 31 Mar 2012, 11:33

Re: Automated Media Center: --def exec option

Post by Hematot »

Hi Hausner,
what I do is to pass along {file} from uTorrent like this:

'some stuff here' --def "exec=E:/batfiles/tvixcopy.bat ""{file}""" 'other --def args here'

Then in my batch file (tvixcopy.bat) I check if the target drive is U: (only my TV shows are renamed to that drive) and if so copy the file to E:

echo off
rem echo Full filename: %~f1
rem echo Parsed filename parts:
rem echo Drive letter only: %~d1
rem echo Path only: %~p1
rem echo File name only: %~n1
rem echo Extension only: %~x1
rem echo Target file name: E:\TVshows\%~nx1

if /i "%~d1" equ "U:" (
copy "%~f1" "E:\TVshows\%~nx1"
)


But as you can see in the rem'd rows, you can extract most anything!
Take a look at ss64.com: http://ss64.com - especially http://ss64.com/nt/syntax-args.html.

First test your syntax by calling a bat file that only echoes your parsed file name parts so you know when you've got your quotes and other things right.
Then move along to the actual stuff you wanna do (in my case the 'if then copy').
Hope this is some help for you.
/D

Btw, don't you want {file} as it is? It is the complete path with file name and everything...?
jojo73
Posts: 1
Joined: 09 Feb 2014, 14:00

Re: Automated Media Center: --def exec option

Post by jojo73 »

Hi

I have a synology nas and am very new to filebot etc. But I've been very interested to read this post as I'd love to do some automation on my setup but don't know where to start! If there's any kind soul out there that would be happy to point me in the right direction I would be eternally grateful :D

Basically, I would like to add TV shows and movies to a downloads folder and from there filebot will automatically rename them accordingly and then sort them into the relevant folders (movies and TV shows - ideally by season) and handbrake will convert them to the mp4 format I need them to be in.

So far I've only managed to get filebot to sort them into folders and rename them in the format I want but I still need to set filebot off manually at the moment and tell it whether its a movie or a tv show. Its a small step in the right direction at least! :? It certainly sounds possible to achieve what I want from what I've been reading here though.....

So if anyone feels able to help me at all, it would be greatly appreciated!

Many thanks
Post Reply