Using Workflows In Powershell

خرید بک لینک

I have been using just a standard foreach loop, which executes as it should. However, I have an 8 core processor and 16GB of RAM and thought I would utilize such with a Parallel.foreach loop. Well, this syntax works as it should

$filelist = Get-ChildItem G:GoodFilesForServer -filter *.mkv
$num = $filelist | measure
$filecount = $num.count 
$i = 0;
ForEach ($file in $filelist)
{
    $Workflow:i++;
    $oldfile = $file.DirectoryName + "" + $file.BaseName + $file.Extension;
    $newfile = $file.DirectoryName + "" + $file.BaseName + ".mp4";      
    $progress = ($Workflow:i / $filecount) * 100
    $progress = [Math]::Round($progress,2)
    Clear-Host
    Write-Host -------------------------------------------------------------------------------
    Write-Host Handbrake Batch Encoding
    Write-Host "Processing - $oldfile"
    Write-Host "File $Workflow:i of $filecount - $progress%"
    Write-Host -------------------------------------------------------------------------------
    Start-Process "C:Program FilesHandBrakeHandBrakeCLI.exe" -ArgumentList "-i `"$oldfile`" -t 1 --angle 1 -c 1 -o `"$newfile`" -f mp4  -O  --decomb --modulus 16 -e x264 -q 32 --vfr -a 1 -E lame -6 dpl2 -R Auto -B 48 -D 0 --gain 0 --audio-fallback ffac3 --x264-preset=veryslow  --x264-profile=high  --x264-tune=`"animation`"  --h264-level=`"4.1`"  --verbose=0" -Wait -NoNewWindow
    del $oldfile
}

Simple enough, but it is not Parallel this syntax does not work, and no error is shown to help me determine why it does not work.

Workflow ParallelTest
{
  $filelist = Get-ChildItem G:GoodFilesForServer -filter *.mkv
  $num = $filelist | measure
  $filecount = $num.count 
  $i = 0;
  ForEach -Parallel -ThrottleLimit 20 ($file in $filelist)
  {
    $Workflow:i++;
    $oldfile = $file.DirectoryName + "" + $file.BaseName + $file.Extension;
    $newfile = $file.DirectoryName + "" + $file.BaseName + ".mp4";      
    $progress = ($Workflow:i / $filecount) * 100
    $progress = [Math]::Round($progress,2)
    Clear-Host
    Write-Host -------------------------------------------------------------------------------
    Write-Host Handbrake Batch Encoding
    Write-Host "Processing - $oldfile"
    Write-Host "File $Workflow:i of $filecount - $progress%"
    Write-Host -------------------------------------------------------------------------------
    Start-Process "C:Program FilesHandBrakeHandBrakeCLI.exe" -ArgumentList "-i `"$oldfile`" -t 1 --angle 1 -c 1 -o `"$newfile`" -f mp4  -O  --decomb --modulus 16 -e x264 -q 32 --vfr -a 1 -E lame -6 dpl2 -R Auto -B 48 -D 0 --gain 0 --audio-fallback ffac3 --x264-preset=veryslow  --x264-profile=high  --x264-tune=`"animation`"  --h264-level=`"4.1`"  --verbose=0" -Wait -NoNewWindow
    del $oldfile
  }
}

What should I alter in my Workflow syntax in order to be able to run the conversion in Parallel (btw, if a ThrottleLimit of 20 is insane to try, we can decrease that)

Recent Questions...

ما را در سایت Recent Questions دنبال می‌کنید

برچسب: نویسنده: استخدام کار بازدید: 269 تاريخ: چهارشنبه 16 تير 1395 ساعت: 2:44

صفحه بندی