Closed ESClaus closed 4 years ago
@TheClaus I'm not a PowerShell nerd (yet) so I don't know how to fix this. But I'm sure @khaosx or others in the HiveMind™ do know.
Stay tuned. We will get you the help you need...
Here's my powershell wrapper, which may provide some inspiration:
#!/usr/bin/env pwsh
param($directory, [switch]$sw, [switch]$dryrun)
$source = Join-Path $directory $(Get-ChildItem $directory -Filter *.mkv -Name)
$crop = Get-Content $(Join-Path $directory crop.txt)
if (Test-Path $(Join-Path $directory notes.txt))
{
$extra_args = Get-Content $(Join-Path $directory notes.txt)
}
if ($sw)
{
if ($extra_args)
{
"Warning: Extra args ignored"
}
$command = "transcode-video `"$source`" --avbr --quick --target big --crop $crop --audio-width main=surround --add-subtitle eng"
}
else
{
$command = "other-transcode `"$source`" --hevc --nvenc-temporal-aq --keep-ac3-stereo --burn-subtitle auto --add-subtitle eng $extra_args"
}
$command
if ($dryrun)
{
Invoke-Expression "$command --dry-run"
}
else
{
Invoke-Expression $command
}
I think they key bit is Invoke-Expression
, and replacing & $command $args $mediaPath
with Invoke-Expression "$command $args $mediaPath"
would do it, but I've not tested
Thanks so much @samhutchins I was able to get things working. Was about ready to pull my hair out and I don't have a lot of it.
I will start off with I am new to Powershell. This is my first script and I am trying to pass multiple arguments through the script.
Here is my script. I can pass the --hevc just fine but the --add-audio 1 fails with invalid option. I have tried splitting the options into multiple variables but still it is the same error.
I asked on the Powershell subreddit and they suggested the array.
When I manually put the options in it works everytime.
$file = Get-ChildItem -Path C:\Media\Input\BD -Filter *.mkv $command = 'other-transcode.bat' $args = @("--hevc","--add-audio 1")
Set-Location -Path C:\Media\Output
foreach($media in $file) { $mediaPath = $media.fullname & $command $args $mediaPath }
Any help would be appreciated.