-3
我想讓這個腳本根據文件名做一個子目錄比較,然後只有30天或更小的文件。語法似乎可以接受,但HandbrakeCLI編碼不會啓動。Powershell腳本運行但沒有任何反應
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'"
}
非常感謝你Joey。 – Darkmalik88
看來每個對象循環都沒有填充$ results變量。 – Darkmalik88
如何重寫$ results = @(compare-object $ s1 $ d1)| Where-Object {$ _。Name -ne $ _。Name}因此,它比較了兩個目錄和ingnores匹配的文件名。只有將不匹配的文件名傳遞給手剎? – Darkmalik88