Skip to content

Instantly share code, notes, and snippets.

@rkaiser0324
Last active December 10, 2019 17:16
Show Gist options
  • Select an option

  • Save rkaiser0324/99f6a5ef158f5b7b7adc3e15a9c9fb6b to your computer and use it in GitHub Desktop.

Select an option

Save rkaiser0324/99f6a5ef158f5b7b7adc3e15a9c9fb6b to your computer and use it in GitHub Desktop.
Recursively scan a directory of videos, and transcode them appropriately for iPad using HandbrakeCLI.exe
# convert-for-itunes.ps1
#
# convert-for-itunes.ps1 <c:/path/to/handbrakecli.exe> <c:/path/to/input/directory> <c:/path/to/output/directory>
param([string]$handbrakeclipath,[string]$inputpath,[string]$outputpath)
echo 'Checking ' + $inputpath + ' ...';
get-childitem -LiteralPath "$inputpath" -Recurse | where { ($_.extension -eq ".mp4") -or ($_.extension -eq ".avi") } | % {
$basename = $_.BaseName + ".mp4";
$outputfile = $outputpath + "\" + $basename;
if (!([System.IO.File]::Exists($outputfile)))
{
#$cmd = $handbrakepath + ' --preset "Very Fast 480p30" --start-at duration:600 --stop-at duration:30 -i "' + $_.FullName + '" -o "' + $outputfile + '"';
$cmd = $handbrakeclipath + ' --preset "Very Fast 480p30" -i "' + $_.FullName + '" -o "' + $outputfile + '"';
echo $cmd;
iex $cmd;
}
else
{
echo "SKIPPING $basename";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment