Illegal usage: output folder must exist and must be a directory

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

Illegal usage: output folder must exist and must be a directory

Post by stephen147 » 07 Mar 2019, 21:26

I've got a .bat file (saved here: Z:\Movies & TV\_TO DO) with the following:

Code: Select all

filebot -script fn:amc --output /output --def [email protected]"Z:/Movies & TV/_TO DO/MovieFormat.txt" --action duplicate --conflict auto -non-strict "Z:/Movies & TV/_TO DO/_NOT DONE" --log-file "Z:/Movies & TV/_TO DO/_AMC Log Files/amc.log" --def excludeList="Z:/Movies & TV/_TO DO/_AMC Log Files/amc_excludelist.txt" --def unsorted=y artwork=y storeReport=y clean=y
@pause
As you can see my path contains an ampersand which is making life difficult.

How can I escape this?

My movieformat.txt (saved here: Z:\Movies & TV\_TO DO) file contains this multiline code:

Code: Select all

movieFormat=Z:/Movies & TV/_TO DO/_DONE/
 {hd.matches(/(?i)SD/) ? "480p-720p" : ""}
 {hd.matches(/(?i)HD/) ? "720p-1080p" : ""}
 {hd.matches(/(?i)UHD/) ? "4k" : ""}
/
 {n.replace(':','-').replaceAll(/[\/:*?"<>|]/,' - ')}
 ({y})
 {fn.matches(/(?i).+\b25th.+?anniv.+/) ? "(25th Anniv. Edition)" : ""}
 {fn.matches(/(?i).+\b\(limited\b.*?\).+/) ? "(Limited Edition)" : ""}
 {fn.matches(/(?i).+\b\(uncut\b.*?\).+/) ? "(Uncut)" : ""}
 {fn.matches(/(?i).+\bcollector.+?s.+?edition\b.+/) ? "(Collector's Edition)" : ""}
 {fn.matches(/(?i).+\bdirect.+?cut\b.+/) ? "(Director's Cut)" : ""}
 {fn.matches(/(?i).+\bextended.+?\b.+/) ? "(Extended)" : ""}
 {fn.matches(/(?i).+\bextended.+?edit\b.+/) ? "(Extended Edition)" : ""}
 {fn.matches(/(?i).+\bimax\b.+/) ? "(IMAX Edition)" : ""}
 {fn.matches(/(?i).+\blimited\b.+/) ? "(Limited)" : ""}
 {fn.matches(/(?i).+\bremastered\b.+/) ? "(Remastered)" : ""}
 {fn.matches(/(?i).+\bsuper.+duper.+cut\b.+/) ? "(Super Duper Cut)" : ""}
 {fn.matches(/(?i).+\btheatrical\b.+/) ? "(Theatrical)" : ""}
 {fn.matches(/(?i).+\bunrated\b.+/) ? "(Unrated)" : ""}
 {any{fn.match(/\([^\()+?[^\d]+?\)\s*/)} {""}{''}}
 {self.vf ? self.vf + "" : self.hpi}
 {hd}
 {"${self.source ?: 'WEB-DL'}"}
 {fn.matches(/(?i).+\bremux\b.+/) ? "REMUX" : ""}
 {ac}
 {audio[0].channels.replaceAll(/^(\d{1}).*/,'$1').replaceAll(/2/, "2ch").replaceAll(/6/, "5.1ch").replaceAll(/7/, "6.1ch").replaceAll(/8/, "7.1ch").replaceAll(/Object.+.*/, "Object-Based 7.1ch")}
 {vc}{
audio.collect { s ->
	allOf
		{any
			{s.'CodecID/Hint'}
			{s.'Codec'.contains('DTS-HD') ? s.'Codec': null}
			{s.'Format'}
		}
		{s.'Format_Profile'}*.replaceAll('/ MA|/ Core|/ ES Matrix|/ TrueHD')*.replaceAll('AC-3', 'AC3').join('.')
}.flatten()*.trim().join(', ').matches(/(?i).*Atmos.*/) ? " TrueHD+Atmos" : ""
}_{any{"$group"}{fn.match(/(?<=[_-])[^\s_-]+?$/)}{'NA'}.replaceAll(/[-_\[\]]\s*|\.\w{3}$/, "")}
/
{n.replace(':','-').replaceAll(/[\/:*?"<>|]/,' - ')}
 ({y})
 {fn.matches(/(?i).+\b25th.+?anniv.+/) ? "(25th Anniv. Edition)" : ""}
 {fn.matches(/(?i).+\b\(limited\b.*?\).+/) ? "(Limited Edition)" : ""}
 {fn.matches(/(?i).+\b\(uncut\b.*?\).+/) ? "(Uncut)" : ""}
 {fn.matches(/(?i).+\bcollector.+?s.+?edition\b.+/) ? "(Collector's Edition)" : ""}
 {fn.matches(/(?i).+\bdirect.+?cut\b.+/) ? "(Director's Cut)" : ""}
 {fn.matches(/(?i).+\bextended.+?\b.+/) ? "(Extended)" : ""}
 {fn.matches(/(?i).+\bextended.+?edit\b.+/) ? "(Extended Edition)" : ""}
 {fn.matches(/(?i).+\bimax\b.+/) ? "(IMAX Edition)" : ""}
 {fn.matches(/(?i).+\blimited\b.+/) ? "(Limited)" : ""}
 {fn.matches(/(?i).+\bremastered\b.+/) ? "(Remastered)" : ""}
 {fn.matches(/(?i).+\bsuper.+duper.+cut\b.+/) ? "(Super Duper Cut)" : ""}
 {fn.matches(/(?i).+\btheatrical\b.+/) ? "(Theatrical)" : ""}
 {fn.matches(/(?i).+\bunrated\b.+/) ? "(Unrated)" : ""}
 {any{fn.match(/\([^\()+?[^\d]+?\)\s*/)} {""}{''}}
 {self.vf ? self.vf + "" : self.hpi}
 {hd}
 {"${self.source ?: 'WEB-DL'}"}
 {fn.matches(/(?i).+\bremux\b.+/) ? "REMUX" : ""}
 {ac}
 {audio[0].channels.replaceAll(/^(\d{1}).*/,'$1').replaceAll(/2/, "2ch").replaceAll(/6/, "5.1ch").replaceAll(/7/, "6.1ch").replaceAll(/8/, "7.1ch").replaceAll(/Object.+.*/, "Object-Based 7.1ch")}
 {vc}{
audio.collect { s ->
	allOf
		{any
			{s.'CodecID/Hint'}
			{s.'Codec'.contains('DTS-HD') ? s.'Codec': null}
			{s.'Format'}
		}
		{s.'Format_Profile'}*.replaceAll('/ MA|/ Core|/ ES Matrix|/ TrueHD')*.replaceAll('AC-3', 'AC3').join('.')
}.flatten()*.trim().join(', ').matches(/(?i).*Atmos.*/) ? " TrueHD+Atmos" : ""
}_{any{"$group"}{fn.match(/(?<=[_-])[^\s_-]+?$/)}{'NA'}.replaceAll(/[-_\[\]]\s*|\.\w{3}$/, "")}{any{'.'+lang}{lang}}{fn.matches(/(?i).+sdh.+/) ? "_SDH" : ""}{any{fn.match(/(?i)\(foreignpartsonly\)/)}{''}}{"."+ext}
The CMD error is:

Code: Select all

Illegal usage: output folder must exist and must be a directory: Z:\output
Failure (°_°)
Press any key to continue . . .
The Z:/Movies & TV/_TO DO/_DONE folder does exist though.

Thanks in advance.

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

Re: Illegal usage: output folder must exist and must be a directory

Post by rednoah » 07 Mar 2019, 21:38

1.
This error is completely unrelated to any custom format you might be using:

Code: Select all

Illegal usage: output folder must exist and must be a directory: Z:\output

This error message is pointing us towards a bad output folder value:

Code: Select all

--output /output

Presumably, you mean to do this:

Code: Select all

--output "Z:/Movies & TV/_TO DO/_DONE"


2.
The format file is also wrong. Just kill the first line and it'll be fine.

NO:

Code: Select all

movieFormat=Z:/Movies & TV/_TO DO/_DONE/
 {hd.matches(/(?i)SD/) ? "480p-720p" : ""}
 ...
YES:

Code: Select all

 {hd.matches(/(?i)SD/) ? "480p-720p" : ""}
 ...
:idea: Please read the FAQ and How to Request Help.

stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

Re: Illegal usage: output folder must exist and must be a directory

Post by stephen147 » 08 Mar 2019, 15:54

Great, thank you. Now one thing left to update the Kodi database.

Here's what I've got, for anyone as stoopid as me!! :roll:

In the folder: Z:\Movies & TV\_TO DO\_TO DO there is:
Filebot Scraper.bat
Movie Format.groovy
Anime Format.groovy
TV Format.groovy
+ All the unsorted movies


Z:/Movies & TV/_TO DO/_DONE folder path must exist so the script can move the completed items which will then be formatted like so:
_DONE/720p-1080p/Who Am I (2014) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_VietHD/Who Am I (2014) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_VietHD.mkv


Filebot Scraper.bat

Code: Select all

@echo off
color 5F
mode con:cols=310 lines=80

filebot -script fn:amc --output "Z:/Movies & TV/_TO DO/_DONE" ^
--action move --conflict auto -non-strict "Z:/Movies & TV/_TO DO/_TO DO" ^
--def excludeList="Z:/Movies & TV/_TO DO/_TO DO/_AMC Log Files/amc_excludelist.groovy" ^
--def [email protected]"Z:/Movies & TV/_TO DO/_TO DO/Anime Format.groovy" ^
--def [email protected]"Z:/Movies & TV/_TO DO/_TO DO/Movie Format.groovy" ^
--def [email protected]"Z:/Movies & TV/_TO DO/_TO DO/TV Format.groovy" ^
--def artwork=y ^
--def target=folder ^
--def clean=y ^
--def deleteAfterExtract=y ^
--def extras=y ^
--def skipExtract=n ^
--def storeReport=y ^
--def unsorted=n ^
--def kodi=169.254.146.80:8080 ^
--log-file "Z:/Movies & TV/_TO DO/_TO DO/_AMC Log Files/amc.log"
goto PROCESS_COMPLETE

:PROCESS_COMPLETE
rem echo:
echo:--------------------------------------------
color 0E
echo:
echo:   PROCESS COMPLETE !
echo:
echo:--------------------------------------------
@echo off
timeout /T 6
rem @pause
EXIT

Movie Format.groovy

Code: Select all

{
def space = call{' '}
// Audio
def ChannelString = any{(0.0+audio.'ChannelPositionsString2'*.replaceAll(/Object\sBased\s\/|0.(?=\d.\d)/, '')*.split(' / ')*.collect{ it.split('/')*.toBigDecimal().sum() }*.max().max()).toString()}{channels};
def codecSubVersion = any{audio.any{ a -> call{a.FormatProfile} =~ 'HRA' } ? '.HRA' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'X / MA / Core' } ? '-X' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'MA / Core' } ? '.MA' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'ES Matrix / Core' } ? '-ES' : null}{null};
def codecVersion = any{audio.Codec.join().match(/DTS-HD/)+codecSubVersion+'.'+audio.Codec.join().match(/TrueHD/)}{audio.Codec.join().match(/DTS-HD/) && codecSubVersion == '-X' ? 'DTS-X' : null}{audio.Codec.join().match(/DTS-HD/)+codecSubVersion}{audio.Codec.join().match(/TrueHD/)}{audio.Codec.join().match(/DTS/)+codecSubVersion.replaceAll(/null/)}{ac};
// Movies directories
def dir_root = call{'Z:/Movies & TV/'};
def dir_main =
call{hd.matches(/(?i)SD/) ? '480p-720p/' : ''}+
call{hd.matches(/(?i)HD/) ? '720p-1080p/' : ''}+
call{hd.matches(/(?i)UHD/) ? '4k/' : ''};
// Main Title
def main_title =
call{n.replace(':','-').replaceAll(/[\/:*?"<>|]/,' - ')}+
space + '(' + call{y} + ')'+
call{fn.matches(/(?i).+\b25th.+?anniv.+/) ? ' (25th Anniv. Edition)' : ''}+
call{fn.matches(/(?i).+\b\(limited\b.*?\).+/) ? ' (Limited Edition)' : ''}+
call{fn.matches(/(?i).+\b\(uncut\b.*?\).+/) ? ' (Uncut)' : ''}+
call{fn.matches(/(?i).+\bcollector.+?s.+?edition\b.+/) ? ' (Collector\'s Edition)' : ''}+
call{fn.matches(/(?i).+\bdirect.+?cut\b.+/) ? '(Director\'s Cut)' : ''}+
call{fn.matches(/(?i).+\bextended.+?\b.+/) ? '(Extended)' : ''}+
call{fn.matches(/(?i).+\bextended.+?edit\b.+/) ? '(Extended Edition)' : ''}+
call{fn.matches(/(?i).+\bimax\b.+/) ? '(IMAX Edition)' : ''}+
call{fn.matches(/(?i).+\blimited\b.+/) ? '(Limited)' : ''}+
call{fn.matches(/(?i).+\bremastered\b.+/) ? '(Remastered)' : ''}+
call{fn.matches(/(?i).+\bsuper.+duper.+cut\b.+/) ? '(Super Duper Cut)' : ''}+
call{fn.matches(/(?i).+\btheatrical\b.+/) ? '(Theatrical)' : ''}+
call{fn.matches(/(?i).+\bunrated\b.+/) ? '(Unrated)' : ''}+
call{any{fn.match(/\([^\()+?[^\d]+?\)\s*/)} {''}{''}}+
space + call{self.vf ? self.vf : self.hpi}+
space + call{hd}+
space + call{source.matches(/(?i)blu.*ray/) ? 'Blu-ray' : {source} ?: 'WEB-DL'}+
space + call{fn.matches(/(?i).+\bremux\b.+/) ? 'REMUX' : ''}+
space + call{self.hdr ? self.hdr + bitdepth + 'bit' : 'non-HDR'}+
space + call{vc}+
space + call(allOf{codecVersion.replaceAll(/null/)}{ChannelString + 'ch'}{aco.match(/Atmos/)}).join(' ')+
'_'+
call{any{"$group"}{fn.match(/(?<=[_-])[^\s_-]+?$/)}{'NA'}.replaceAll(/[-_\[\]]\s*|\.\w{3}$/, '')};
def lang = call{any{'.'+lang}{lang}}+{fn.matches(/(?i).+sdh.+/) ? '_SDH' : ''}{any{fn.match(/(?i)\(foreignpartsonly\)/)}{''}};
def ext = call{'.'+ext};

(dir_main + '/' + main_title + '/' + main_title + lang).replaceAll(/null/)
//end
}
Last edited by stephen147 on 27 Apr 2019, 18:48, edited 6 times in total.

stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

Re: Illegal usage: output folder must exist and must be a directory

Post by stephen147 » 15 Apr 2019, 12:33

Is there any way to pass a folder argument in the bat file to the lines such as:

Code: Select all

set TODO_FOLDER="_TO DO"
--action move --conflict auto -non-strict "Z:/Movies & TV/%%TODO_FOLDER%%/%%TODO_FOLDER%%" ^
It throws an error:

Code: Select all

Cannot read @file

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

Re: Illegal usage: output folder must exist and must be a directory

Post by rednoah » 15 Apr 2019, 13:17

Yes, but the error message you get is probably completely unrelated to that and caused by something completely different, probably just bad command line args.
:idea: Please read the FAQ and How to Request Help.

stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

Re: Illegal usage: output folder must exist and must be a directory

Post by stephen147 » 29 Apr 2019, 10:46

Fixed that issue for anyone else wanting to pass args too.

Code: Select all

set "EXCLIST=amc_excludelist.groovy"
set "FOLDER_LOG=_AMC Log Files"
set "FOLDER_PROCESS=_To Process"
set "FOLDER_ROOT=Z:/Movies & TV/_Newly DL'd"
set "GROOVY_ANIME=Anime Format.groovy"
set "GROOVY_MOVIE=Movie Format.groovy"
set "GROOVY_TV=TV Format.groovy"
set "LOG=amc.log"

filebot -script fn:amc --output "%FOLDER_ROOT%" ^
--action move --conflict auto -non-strict "%FOLDER_ROOT%/%FOLDER_PROCESS%" ^
--def excludeList="%FOLDER_ROOT%/%FOLDER_PROCESS%/%FOLDER_LOG%/%EXCLIST%" ^
--def [email protected]"%FOLDER_ROOT%/%GROOVY_ANIME%" ^
--def [email protected]"%FOLDER_ROOT%/%GROOVY_MOVIE%" ^
--def [email protected]"%FOLDER_ROOT%/%GROOVY_TV%" ^
--def artwork=%DL_EXTRAS_ANS% ^
--def target=folder ^
--def clean=y ^
--def deleteAfterExtract=y ^
--def extras=y ^
--def skipExtract=n ^
--def storeReport=y ^
--def unsorted=n ^
--def kodi=169.254.146.80:8080 ^
--log-file "%FOLDER_ROOT%/%FOLDER_PROCESS%/%FOLDER_LOG%/%LOG%"

Post Reply