FileBot AMC Feed New Filenames/Directories Into .Txt File & Trigger .Bat Script

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
whereswaller
Posts: 21
Joined: 05 Mar 2015, 21:59

FileBot AMC Feed New Filenames/Directories Into .Txt File & Trigger .Bat Script

Post by whereswaller » 06 Jan 2019, 09:11

Hi,
I'm in the process of enhancing my AMC (automated media centre) functionality for processing music by coupling FileBot functionality with some ancillary scripts.

One of these scripts uses FFMPEG to standardise all music file formats and bitrates.

In order to automate the triggering of this script, I am hoping someone can assist me with three questions:

a) how can FileBot's AMC script be configured to output a .txt file containing a list of music filenames/directories from a just processed download? (this will be used by the FFMPEG using script)

b) how can FileBot's AMC script trigger a .bat script in Windows upon completing processing of each download? (this will trigger the start of the FFMPEG using script)

c) does FileBot's AMC script run multiple instances concurrently or does a second instance not load until the first has fully completed processing a download? (in other words, is there is a risk that the script will try to run on two different downloads simultaneously and, in doing so, pollute/corrupt the .txt file)

Many thanks for any help you can provide.

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

Re: FileBot AMC Feed New Filenames/Directories Into .Txt File & Trigger .Bat Script

Post by rednoah » 06 Jan 2019, 10:45

a) and b)
I think the --def exec option can be used for this.

e.g.

Code: Select all

--def exec="echo {quote f}"
So you can call an arbitrary program or script that write file paths passed in via arguments into a text file or database of your choice.

Here's some docs & examples for the -exec filebot option and the --def exec amc script option:
viewtopic.php?f=4&t=5047


c)
As long as you use the same --log-file, each script call will be executed in sequence, and never in parallel. That's because each filebot instance will lay dormant until it can get an exclusive read-write lock on the log file.
:idea: Please read the FAQ and How to Request Help.

Yaiesi
Posts: 1
Joined: 10 Jan 2019, 13:14

Re: FileBot AMC Feed New Filenames/Directories Into .Txt File & Trigger .Bat Script

Post by Yaiesi » 10 Jan 2019, 13:30

rednoah wrote:
06 Jan 2019, 10:45
a) and b)
I think the --def exec option can be used for this.

e.g.

Code: Select all

--def exec="echo {quote f}"
So you can call an arbitrary program or script that write file paths passed in via arguments into a text file or database of your choice.

Here's some docs & examples for the -exec filebot option and the --def exec amc script option:
viewtopic.php?f=4&t=5047


c)
As long as you use the same --log-file, each script call will be executed in sequence, and never in parallel. That's because each filebot instance will lay dormant until it can get an exclusive read-write lock on the log file.
Thank you for this help!

whereswaller
Posts: 21
Joined: 05 Mar 2015, 21:59

Re: FileBot AMC Feed New Filenames/Directories Into .Txt File & Trigger .Bat Script

Post by whereswaller » 19 Jan 2019, 05:48

Hi rednoah,
Given your explanation, I've changed my approach a little. I am going to pass the folder directory from FileBot straight to the batch script.

I'm using the following code in my FileBot AMC script to launch the .bat file.

Code: Select all

--def "exec=cmd /c C:\ffmpeg\bin\128kbps-mp3-convert2.bat \"{file}\" \"{fn}\" \"{ext}\" \"{folder}\""
I have two questions I'm hoping you can assist with:

1. What batch file variable names would FileBot pass these groovy variables under?

2. How can I have this batch file only execute if the downloaded files are music?

Many thanks for any help you can provide,
James

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

Re: FileBot AMC Feed New Filenames/Directories Into .Txt File & Trigger .Bat Script

Post by rednoah » 19 Jan 2019, 06:06

1.
FileBot just makes a command-line call, as defined by your template. In your case, {file} will be passed as 1st argument, {fn} will be passed as 2nd argument, etc.

:arrow: https://www.tutorialspoint.com/batch_sc ... iables.htm



2.
A more clean approach might look like this:

Code: Select all

--def "exec=amc-handler-{ext} {quote folder, file, fn, ext}"
Now you just need to add a few custom scripts to the %PATH%, such as amc-handler-mp3, amc-handler-flac, etc.


You can also add a few empty scripts like amc-handler-mkv or amc-handler-mp4 that just do nothing:

Code: Select all

@echo off 
echo "amc-handler-mkv"
echo %1 
echo %2 
echo %3
echo %4
:idea: Please read the FAQ and How to Request Help.

whereswaller
Posts: 21
Joined: 05 Mar 2015, 21:59

Re: FileBot AMC Feed New Filenames/Directories Into .Txt File & Trigger .Bat Script

Post by whereswaller » 21 Jan 2019, 11:10

Hi rednoah,
Thanks for help as always.

Apologies, I didn't follow part 2 of your response. Is there no way to only execute the batch if the files being processed are music?

Are amc-handler-mp3, amc-handler-flac etc. built in scripts within Filebot or just dummy names you were giving potential .bat scripts I have written?

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

Re: FileBot AMC Feed New Filenames/Directories Into .Txt File & Trigger .Bat Script

Post by rednoah » 21 Jan 2019, 11:30

Yes and no. You have to call something, but you can call different things (including a no-op command that does nothing) for different files.

Having a set of amc-handler-{ext} scripts is just an example. It could be anything. It's not built-in. My example generates commands with amc-handler-{ext} so it follows that scripts like amc-handler-mp4 would be executed. It could be anything though.

:idea: --def exec uses FileBot format expressions to generate command-line commands and execute them. Any commands. Anything you can type yourself in CMD will work.
:idea: Please read the FAQ and How to Request Help.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests