Option "--format" takes an operand

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

Option "--format" takes an operand

Post by stephen147 »

Using powershell with this code saved as a .ps1 file:

Code: Select all

Get-Content "Z:/Movies & TV/_Newly DL'd/Movie Format.groovy" | Select-String -pattern "^.*//+|^\s*$" -notmatch
filebot -script fn:sysenv --format "$FORMAT"
# filebot -script fn:renall "Z:/Movies & TV/_Newly DL'd/_To Process" -non-strict --format "$FORMAT" --db TheMovieDB --action test --log info
It returns an error:

Code: Select all

Option "--format" takes an operand
Along with using this format code. PS. I came across this problem before and it was the format code at fault but I cannot fix this issue.

Code: Select all

{n} ({y})_{
	def mCFP =
	[
	'AAC LC SBR' : 'AAC',
	'AAC LC' : 'AAC',
	'AC 3 Dep' : 'E-AC3',
	'AC 3' : 'AC3',
	'DTS 96 24' : 'DTS 96-24',
	'DTS ES XBR' : 'DTS-HD HRA',
	'DTS ES XLL' : 'DTS-HD MA',
	'DTS ES XXCH XBR' : 'DTS-HD HRA',
	'DTS ES XXCH XLL' : 'DTS-HD MA',
	'DTS ES XXCH' : 'DTS-ES',
	'DTS ES' : 'DTS-ES',
	'DTS XBR' : 'DTS-HD HRA',
	'DTS XLL X' : 'DTS X',
	'DTS XLL' : 'DTS-HD MA',
	'DTS' : 'DTS',
	'E AC 3 JOC' : 'EAC3 Atmos',
	'E AC 3' : 'EAC3',
	'MLP FBA 16 ch' : 'TrueHD Atmos',
	'MLP FBA' : 'TrueHD',
	'MP3' : 'MP3',
	'PCM' : 'PCM'
	];
	def audioClean = { it.replaceAll(/[\p{Pd}\p{Space}]/, ' ').replaceAll(/\p{Space}{2,}/, ' ').slash(' ') };
	def channelClean = { it.replaceAll(/Debug.+|Object\sBased\s?\/?|(\d+)?\sobjects\s\/\s|0.(?=\d.\d)|20/).replaceAll(/6/,'5.1').replaceAll(/8/,'7.1') };
	def collection = audio.collect
	{ au ->
		def channels = any{ channelClean(au['ChannelPositionsString2'])}{ channelClean(au['ChannelsOriginal'])}{ channelClean(au['Channels']) };
		def dynChannel = {au['NumberOfDynamicObjects'] + 'Obj'};
		def ch = channels.tokenize('\\/').take(3)*.toDouble().inject(0, { a, b -> a + b }).findAll { it > 0 }.max().toString() + 'ch';
		def codec = audioClean(any{ au['CodecID/Hint'] }{ au['Format'] });
		def format_profile = { ( au['Format_AdditionalFeatures'] != null) ? audioClean(au['Format_AdditionalFeatures']) : '' };
		def combined = allOf{codec}{format_profile}.join(' ');
		def stream = allOf { mCFP.get(combined, 'UNKNOWN_FORMAT--'+combined+'--') } { dynChannel } { ch };
	};
	// call{n} + ' (' + call{y} + ') ' + 
	call(collection[0].join( ' ' ));
}
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Option "--format" takes an operand

Post by rednoah »

$FORMAT isn't set, so it says Option "--format" takes an operand because --format requires a value.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Option "--format" takes an operand

Post by rednoah »

@" ... "@ works just fine. Value passed in is identical to the one specified in the ps1 script.

Code: Select all

$FORMAT = @"
{n} ({y})_{
	def mCFP =
	[
	'AAC LC SBR' : 'AAC',
	'AAC LC' : 'AAC',
	'AC 3 Dep' : 'E-AC3',
	'AC 3' : 'AC3',
	'DTS 96 24' : 'DTS 96-24',
	'DTS ES XBR' : 'DTS-HD HRA',
	'DTS ES XLL' : 'DTS-HD MA',
	'DTS ES XXCH XBR' : 'DTS-HD HRA',
	'DTS ES XXCH XLL' : 'DTS-HD MA',
	'DTS ES XXCH' : 'DTS-ES',
	'DTS ES' : 'DTS-ES',
	'DTS XBR' : 'DTS-HD HRA',
	'DTS XLL X' : 'DTS X',
	'DTS XLL' : 'DTS-HD MA',
	'DTS' : 'DTS',
	'E AC 3 JOC' : 'EAC3 Atmos',
	'E AC 3' : 'EAC3',
	'MLP FBA 16 ch' : 'TrueHD Atmos',
	'MLP FBA' : 'TrueHD',
	'MP3' : 'MP3',
	'PCM' : 'PCM'
	];
	def audioClean = { it.replaceAll(/[\p{Pd}\p{Space}]/, ' ').replaceAll(/\p{Space}{2,}/, ' ').slash(' ') };
	def channelClean = { it.replaceAll(/Debug.+|Object\sBased\s?\/?|(\d+)?\sobjects\s\/\s|0.(?=\d.\d)|20/).replaceAll(/6/,'5.1').replaceAll(/8/,'7.1') };
	def collection = audio.collect
	{ au ->
		def channels = any{ channelClean(au['ChannelPositionsString2'])}{ channelClean(au['ChannelsOriginal'])}{ channelClean(au['Channels']) };
		def dynChannel = {au['NumberOfDynamicObjects'] + 'Obj'};
		def ch = channels.tokenize('\\/').take(3)*.toDouble().inject(0, { a, b -> a + b }).findAll { it > 0 }.max().toString() + 'ch';
		def codec = audioClean(any{ au['CodecID/Hint'] }{ au['Format'] });
		def format_profile = { ( au['Format_AdditionalFeatures'] != null) ? audioClean(au['Format_AdditionalFeatures']) : '' };
		def combined = allOf{codec}{format_profile}.join(' ');
		def stream = allOf { mCFP.get(combined, 'UNKNOWN_FORMAT--'+combined+'--') } { dynChannel } { ch };
	};
	// call{n} + ' (' + call{y} + ') ' + 
	call(collection[0].join( ' ' ));
}
"@

filebot -script fn:sysenv --format "$FORMAT"


If you want to read the format from a file, a little trial and error shows that this works, for some mystical reason that only the PS1 gods can know, but it works nevertheless:

Code: Select all

$FORMAT = Get-Content format.groovy | Out-String

filebot -script fn:sysenv --format "$FORMAT"
:idea: https://stackoverflow.com/questions/809 ... n-powershe
:idea: Please read the FAQ and How to Request Help.
stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

Re: Option "--format" takes an operand

Post by stephen147 »

Thanks. I got it to work straight after I post only I wasn't allowed to spam the thread soon after I'd already posted.

Always after I spend yonks wondering why something doesn't work I get it to work or find the issue after posting a thread.

:!: TLDR User error, AGAIN!!

Forgot to assign the variable $FORMAT in the ps1 file.

WORKING CODE BELOW:

Code: Select all

$FORMAT=Get-Content "Z:/Movies & TV/_Newly DL'd/Movie Format.groovy" | Select-String -pattern "^.*//+|^\s*$" -notmatch
filebot -script fn:sysenv --format "$FORMAT"
But passing the variable like you found out is good too.

I like PowerShell.

Code: Select all

| Select-String -pattern "^.*//+|^\s*$" -notmatch
Part of the code will remove any empty lines and also lines that have been commented out with

Code: Select all

//
in the format file.
Post Reply