Created
April 18, 2017 19:03
-
-
Save scytalezero/ea2d7f79c8bc59b7a2998db5411b2ea1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
For a given path, converts any MKV files to MP4 format using ffmpeg. | |
.EXAMPLE | |
PS C:\> Convert-MKVtoMP4 c:\temp | |
Explanation of what the example does | |
.PARAMETER Path | |
Path that will be processed. | |
.PARAMETER Extension | |
Extension to search for, defaults to MKV | |
#> | |
#List the parameters we expect to get. Path is mandatory, and Extension has a default value if not specified | |
Param([Parameter(Mandatory=$true)]$Path, $Extension="*.mkv") | |
#Find the drive letter | |
$driveLetter = Split-Path $Path -Qualifier | |
#Make the recycle bin path | |
$recyclePath = Join-Path $driveLetter "@Recycle" | |
#Get the list of MKV files in an array | |
$fileList = Get-ChildItem $Path -Filter $Extension | |
foreach ($file in $fileList) { | |
$newName = $file.BaseName + ".mp4" | |
#EchoArgs would be replaced with ffmpeg path | |
EchoArgs.exe -i $file.Name -codec copy $newName | |
#Take off the -WhatIf to make these actually delete | |
Remove-Item $file.FullName -WhatIf | |
#Recursively search the recycle bin on that drive and delete the file if found | |
Get-ChildItem $recyclePath -Filter $file.Name -Recurse | Remove-Item -WhatIf | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment