I'm trying to get this script to do a subdirectory compare based on filename and then only files that are 30 days or younger. The Syntax seems to acceptable but the HandbrakeCLI encoding doesn't launch.
Clear screen
$SourceDir = "\\netshare\testing\Source\*.MP4"
$DestinationDir = "\\netshare\testing\Completed_mp4\*.MP4"
$s1 = get-childitem -path $SourceDir -Recurse -Force | Where-Object {$_.LastWriteTime -gt (Get-Date).addDays(-30)}
$d1 = get-childitem -path $DestinationDir -Recurse
$results = @(compare-object $s1 $d1) | Where-Object {$_.Name -ne $_.Name}
$quantity = $results | measure
$Filecount = $quantity
$Process = 0;
foreach ($result in $results){
Write-Host -----------------------------------------------------------------
Write-Host Handbrake Batch Encoding
$Process++;
$results = $file.DirectoryName + "\" + $file.BaseName + ".MP4";
$progress = ($Process / $filecount) * 100
$progress = [Math]::Round($progress,2)
#Clear-Host
Write-Host "Processing - $results"
Write-Host "File $Process of $Filecount - $progress%"
Write-Host -------------------------------------------------------------------------------
$s1 = get-childitem -path $SourceDir -Recurse -Force | Where-Object {$_.LastWriteTime -gt (Get-Date).addDays(-30)}
$d1 = get-childitem -path $DestinationDir -Recurse
Start-Process "C:\Users\Downloads\HandBrakeCLI-1.0.1-win-x86_64.exe -ArgumentList -q 25 -i '$results' -o '$d1'"
}