Skip to content

Instantly share code, notes, and snippets.

@mullnerz
Created April 21, 2015 21:02
Show Gist options
  • Select an option

  • Save mullnerz/7b0123dd0e6a3cee8e2f to your computer and use it in GitHub Desktop.

Select an option

Save mullnerz/7b0123dd0e6a3cee8e2f to your computer and use it in GitHub Desktop.

Revisions

  1. mullnerz created this gist Apr 21, 2015.
    18 changes: 18 additions & 0 deletions convert-avi.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    # 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"
    }
    }