Here is my little script I am trying to get working. It uses handbrake from the cli to convert an avi. After that I am trying to zip the file with 7zip cli, I cant use the 7zip powershell package. If I run the whole script it will get to the part of zipping and just error out. I have tried running it as a cmd and start process. Its like its not finishing the foreach and just running the next command. The command works if I run it by itself and an already converted file. What am i missing here?
$date = Get-Date -Format yyyy-MM-dd
$filelist = Get-ChildItem C:\dan\VideoConvert\*.avi
$i = 0
ForEach ($file in $filelist)
{
$i++
$oldfile = $file.DirectoryName + "\" + $file.BaseName + $file.Extension;
$newfile = $file.DirectoryName + "\converted$i.mp4";
Start-Process "C:\dan\VideoConvert\HandBrakeCLI.exe" -ArgumentList "-i `"$oldfile`" -o `"$newfile`"" -Wait
}
& "c:\dan\VideoConvert\7z.exe" a -t7z "$date" *.mp4
#Start-Process "c:\dan\VideoConvert\7z.exe" -ArgumentList "a -t7z $date.7z *.mp4 -p"
#Copy-Item c:\dan\VideoConvert\$date.7z \\ssb.local\shares\temp
#Remove-Item c:\dan\VideoConvert\$date.7z