How to input variables into .bat file

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
Amishman
Donor
Posts: 56
Joined: 29 Dec 2013, 15:54

How to input variables into .bat file

Post by Amishman »

I'm having trouble puting the variables from uTorrent into a .bat file that contains my Filebot script.

This is the command I have in the "Run this Program" in uTorrent.

Code: Select all

"C:\Rm_Finished_Torrents\Rm.Finished.Torrents.exe" "C:\Rm_Finished_Torrents\Filebot_Rename.bat" "%D" "%F" "%K" "%N" "%L" "%S"
The .exe just removes the torrent from uTorrent when it is finished downloading.

This is the Filebot script in the .bat file.

Code: Select all

filebot.launcher -script fn:amc --output "G:/" --log-file amc.log --action move --conflict override -non-strict --def "seriesFormat=TV/{n}/{'Season '+s.pad (1)}/{s00e00} {t}/{n} {s00e00} {t}" "movieFormat=New Movies/{n} ({y}) {\"[$vf]\"}/{n} ({y})" --def clean=y --def plex=localhost "ut_dir=%1" "ut_file=%2" "ut_kind=%3" "ut_title=%4" "ut_label=%5" "ut_state=%6"
This is the Logger tab information.
[2014-01-11 22:38:37] Executing: "C:\Rm_Finished_Torrents\Rm.Finished.Torrents.exe" "C:\Rm_Finished_Torrents\Filebot_Rename.bat" "C:\Users\Amishman\Downloads\City of Angels (1998)" "City.of.Angels.1998.BRRip.x264.AAC.m-H.D.mkv" "multi" "City of Angels (1998)" "" "5"
This is my amc.log
Jan 11, 2014 10:38:38 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
Parameter: seriesFormat = TV/{n}/{'Season '+s.pad(1)}/{s00e00} {t}/{n} {s00e00} {t}
Parameter: movieFormat = New Movies/{n} ({y}) {"[$vf]"}/{n} ({y})
Parameter: clean = y
Parameter: plex = localhost
Parameter: ut_dir = 'C:\Users\Amishman\Downloads\City'
Parameter: ut_file = of
Parameter: ut_kind = Angels
Parameter: ut_title = (1998)
Parameter: ut_label = City.of.Angels.1998.BRRip.x264.AAC.m-H.D.mkv
Parameter: ut_state = multi
Done ヾ(@⌒ー⌒@)ノ
The directory is getting split into the other variables. If I run the script from the CLI, with the supplied variables from uTorrent, the script runs perfect. How can I enter variables into the .bat so it does not get split up?
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to input variables into .bat file

Post by rednoah »

You'll have to look into .bat scripting in detail then. It's not passing in arguments as you'd like. In the debugging output there's even '...' so the ' characters are literally passed in somehow by cmd for some reason.

You'll just have to play with it and figure out how to work windows cmd.
:idea: Please read the FAQ and How to Request Help.
User avatar
Ithiel
Power² User
Posts: 204
Joined: 11 Jul 2013, 14:58

Re: How to input variables into .bat file

Post by Ithiel »

Hi Amishman,

I'm not quite sure I understand what you're chasing, but if you're having trouble with determining the parameters it passes, maybe this can help you a little in your troubleshooting?

http://networkadminkb.com/KB/a192/how-t ... class.aspx
There can be only one Power² User
twig123
Posts: 10
Joined: 03 Oct 2012, 01:54

Re: How to input variables into .bat file

Post by twig123 »

I was running into similar issues with folders that had spaces in the name, as I was just setting up FileBot with my utorrent 2 days ago and just got it working yesterday.

I believe the variables that you have in your BAT are messing up (the "ut_dir=%1" "ut_file=%2", etc) possibly because of quotes. I don't think anything but the %1 ("%D" in utorrent) variable are of any use to FileBot itself, so you can likely just exclude those from the FileBot command (which is what I did).

Here are snippets from my utorrent run program string and also my BAT file code that is working:

Utorrent run program (username omitted):

Code: Select all

"C:\Users\{username}\Documents\uTorrent Script\FilebotRenamerScript.bat" "%D" "%N" "%L" "%K" "%F"
FilebotRenamerScript.bat (snippets):
I set the variables manually, before actually calling FileBot

Code: Select all

rem Define variables
set ut_dir=%1
set ut_title=%2
set ut_label=%3
set ut_kind=%4
set ut_file=%5
(Cut out the fluff code, as I have my BAT file doing other operations as well)

Notice, no quotes around the %ut_dir% variable when it is being called in the script...

Code: Select all

"C:\Program Files\FileBot\filebot.exe" -script fn:amc --output "E:\FileBot_Test\Output" --conflict override -non-strict --def artwork=n clean=y backdrops=n "seriesFormat=TV/{n}/{n} - Season {s}/{n.space('.')}.{s.pad(2)}x{e.pad(2)}.-.{t.space('.')}" "movieFormat=Movies/{n} ({y})" %ut_dir% --action copy
This code is working for me (even folders with spaces in the name)

Edit: Oops, almost gave ya'll my email credentials :P
Post Reply