tranm2ts.ps1
$Sourcedir = "\\TV\storage\Recent\"
$Destinationdir = "\\TV\storage\enc\"
$HighRes = "1280x720"
$StdRes = "720x480"
$Resolution = $HighRes
$Homedir = "~"
Set-Location $Sourcedir
Get-ChildItem | Sort-Object @{Expression={$_.LastWriteTime}; Descending=$false} | Format-List -property name > temp.txt
$Source0 = Get-Content temp.txt | Where-Object {$_.trim()}
$Source1 = New-Object object[] $Source0.Length
$Destination = New-Object object[] $Source0.Length
for ( $i = 1; $i -le $Source0.Length; $i++ )
{
$Source1[$i - 1] = $Source0[$i - 1] -replace "Name : ", ""
$SS = $Sourcedir + $Source1[$i - 1]
$Resolution = $HighRes
$Destination[$i - 1] = $Source1[$i - 1]
$DD = $Destinationdir + $Destination[$i - 1]
$DD = $DD.Replace(".m2ts", ".mp4")
Write-Output $DD
ffmpeg.exe -i $SS -c:v libx264 -c:a copy -s $Resolution $DD
}
Set-Location $Homedir