Invalid syntax via Task Scheduler - No issues when ran manually

Any questions? Need some help?
Post Reply
valiantslack
Posts: 15
Joined: 17 Jun 2019, 17:10

Invalid syntax via Task Scheduler - No issues when ran manually

Post by valiantslack »

I updated a script I've been using for a while to include release group in the movie *.mkv name (% { [group] }). Running the below script manually works with no issues.

Code: Select all

filebot -script fn:amc --output "N:/" --action move --conflict skip --def clean=y --def ignore="2160p|AMC|Extracted|Placeholder" --def pushover=********** -non-strict "N:/Media/#Unprocessed" --def movieFormat="N:/Media/Movies/{ any{ certification ==~ /G|PG/ ? 'Family' : 'Adults' }{ 'Adults' } }/{ ~plex ** { ' ' + [vf] + [certification] } % { [group] } }" seriesFormat="N:/Media/TV Shows/{ any{ certification ==~ /TV-Y|TV-Y7/ ? 'Kids TV' : 'Adults' }{ 'Adults'} }/{plex.tail}" --log-file "N:/Media/#Unprocessed/AMC/amc.log" --def excludeList="N:/Media/#Unprocessed/AMC/amcexclude.txt"
However when running the same script via Task Scheduler, I get a syntax error. It appears the (% { [group] }) section is completely missing when run via this method and joining the TV section instead. Not sure why this is the case.

Code: Select all

args[1] = -script
args[2] = fn:amc
args[3] = --output
args[4] = N:/
args[5] = --action
args[6] = move
args[7] = --conflict
args[8] = skip
args[9] = --def
args[10] = clean=y
args[11] = --def
args[12] = ignore=2160p|AMC|Extracted|Placeholder
args[13] = --def
args[14] = pushover=**********
args[15] = -non-strict
args[16] = N:/Media/#Unprocessed
args[17] = --def
args[18] = movieFormat=N:/Media/Movies/{ any{ certification ==~ /G|PG/ ? 'Family' : 'Adults' }{ 'Adults' } }/{ ~plex ** { ' ' + [vf] + [certification] }/Media/TV Shows/{ any{ certification ==~ /TV-Y|TV-Y7/ ? 'Kids TV' : 'Adults' }{ 'Adults'} }/{plex.tail}
args[19] = --log-file
args[20] = N:/Media/#Unprocessed/AMC/amc.log
args[21] = --def
args[22] = excludeList=N:/Media/#Unprocessed/AMC/amcexclude.txt

Script Error: SyntaxError: missing token: }
Failure (×_×)⌒☆
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Invalid syntax via Task Scheduler - No issues when ran manually

Post by rednoah »

:idea: % and : have special meaning in Windows CMD so it's probably interpreted away somehow because you have accidentally introduced %: substring replacement code:
https://ss64.com/nt/syntax-percent.html
https://ss64.com/nt/syntax-replace.html
https://ss64.com/nt/syntax-substring.html


:arrow: Use the @file syntax for reading command-line arguments from external text files, as to avoid the Windows CMD interpreter:

Shell: Select all

--def movieFormat=@/path/to/MovieFormat.groovy seriesFormat=@/path/to/SeriesFormat.groovy

:!: Windows CMD is insane. Never ever use Windows CMD. Always use PowerShell instead.
:idea: Please read the FAQ and How to Request Help.
valiantslack
Posts: 15
Joined: 17 Jun 2019, 17:10

Re: Invalid syntax via Task Scheduler - No issues when ran manually

Post by valiantslack »

I was able to correct the context by changing it to the following:

Code: Select all

.....[certification] } }{ [group] }"....
Also changed to using Powershell.
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Invalid syntax via Task Scheduler - No issues when ran manually

Post by rednoah »

You'll really want to use @files though. That'll solve all future problems as well. Passing complex arguments inline on the command-line inevitably leads to headaches. :lol:
:idea: Please read the FAQ and How to Request Help.
valiantslack
Posts: 15
Joined: 17 Jun 2019, 17:10

Re: Invalid syntax via Task Scheduler - No issues when ran manually

Post by valiantslack »

rednoah wrote: 20 Jun 2023, 17:45 You'll really want to use @files though. That'll solve all future problems as well. Passing complex arguments inline on the command-line inevitably leads to headaches. :lol:
I'll look into doing that next. Thanks for the tip!
Post Reply