Skip to content

Instantly share code, notes, and snippets.

@mullnerz
Created April 21, 2015 21:02
Show Gist options
  • Save mullnerz/7b0123dd0e6a3cee8e2f to your computer and use it in GitHub Desktop.
Save mullnerz/7b0123dd0e6a3cee8e2f to your computer and use it in GitHub Desktop.
mass converting video files using powershell and handbrake
# originated from:
# https://perfp.wordpress.com/2010/08/25/mass-converting-video-files-using-powershell-and-handbrake/
$outdir = "C:\Temp\convert-avi"
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
$files = Get-Childitem -Recurse -Include "*.avi"
foreach ($file in $files) {
$subpath = $file.DirectoryName.Replace((Get-Location -PSProvider FileSystem).ProviderPath , "")
$destdir = $outdir + $subpath
$destname = $destdir + "\" + $file.BaseName + ".mp4"
if (!(Test-Path $destdir)) {
New-Item $destdir -type directory
}
if (!(Test-Path $destname)) {
& "C:\Program Files\Handbrake\HandBrakeCLI.exe" -i $file -t 1 -c 1 -o $destname --preset "Normal"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment