Powershell Batch Converter Script

Hi All,
I've created a Windows Powershell script that provides a GUI for batch file sonversions.

It's knid of self explanitory, but I'll update this post later with full instructions.

Basic setup, Install Powershell, copy and paste the contents below into a text file and name it whatever you want with .ps1 as the file extension, and run with powershell.

note: The easiest way to let powershell run scripts is to set the Execution Policy to unrestricted by running the following command as an admin.

PS>Set-ExecutionPolicy unrestricted

-----------Copy below this line---------------

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

#Region Global Variables
#----Edit the next line to change the default Input folder (otherwise you can select a different folder after the script has been launched)
$InputDir="C:\MoviesToConvert"
#----Edit the next line to change the default Output folder (otherwise you can select a different folder after the script has been launched)
$OutputDir="C:\ConvertedMovies"

#----Edit the next line to specify where Bababoom is installed
$ExePath='"C:\Program Files (x86)\Badaboom2\Badaboom.exe"'
#----Un-comment the next line and comment the above line this one for default 32-bit installations
#$ExePath='"C:\Program Files\Badaboom2\Badaboom.exe"'

$DtaFldFnt=New-Object System.Drawing.Font("Verdana",9)
$DtaFldSiz=New-Object system.Drawing.Size(500,15)
$DtaFldSiz2=New-Object system.Drawing.Size(150,15)
$DtaFldXpos=160
$DtaFldYpos=67
$DefLblXSiz=140
$DefLblYSiz=17
$BatFile=$Env:TEMP + "\badaboombatch.bat"
#$DevInFileName=""
$FilesAddedToBat=$False

#Region Batch File Notice Variable
$BatNote="echo off
color 1f
cls
echo.
echo -------- WARNING closing this window will prevent --------
echo ------- the remaining movies from being transcoded. ------
echo.
echo Feel free to minimize this window while movies are being transcoded.
echo.
echo Note that if you close this window the current movie will continue
echo to be transcoded to completion.
echo.
echo If you would like to cancel the remaining transcoding jobs, close this
echo window and cancel the current job in Badaboom if desired.
echo.
echo.
echo.
echo MOVIES BEING TRANSCODED
echo."
#EndRegion Batch File Notice Variable

#EndRegion Global Variables

#Region Functions

function addlabel ([string]$text,[int]$fsz,[string]$ftyp,[int]$xpo,[int]$ypo,[int]$xsz,[int]$ysz)
{
$Label=New-Object System.Windows.Forms.Label
$Label.Location=New-Object System.Drawing.Size($xpo,$ypo)
$Label.Size=New-Object System.Drawing.Size($xsz,$ysz)
$Label.Text=$text
$Label.Font=new-object System.Drawing.Font("Verdana",$fsz,[System.Drawing.FontStyle]::$ftyp)
$objForm.Controls.Add($Label)
}

function setBitrate
{
$BRSet=$BitRateBox.Text -replace "\.", ""
$BRSet=$BRSet -replace "Mb", ""
$BRSet=$BRSet+"00000"
Set-Variable -Name BitRateVal -Value $BRSet -Scope 1
}

function setResolution
{
$OutResSet=$OutResBox.Text -replace "x", " "
Set-Variable -Name OutRes -Value $OutResSet -Scope 1
}

function SetDeviceDefaults
{
if ($OutDevBox.Text -eq "Apple TV"){$BitRateBox.Text="3.0Mb";$OutResBox.Text="960x540"}
if ($OutDevBox.Text -eq "BlackBerry Bold"){$BitRateBox.Text="1.0Mb";$OutResBox.Text="480x270"}
if ($OutDevBox.Text -eq "BlackBerry Torch"){$BitRateBox.Text="1.0Mb";$OutResBox.Text="480x270"}
if ($OutDevBox.Text -eq "HTC HD7"){$BitRateBox.Text="1.5Mb";$OutResBox.Text="800x450"}
if ($OutDevBox.Text -eq "HTC Droid Incredible"){$BitRateBox.Text="1.0Mb";$OutResBox.Text="800x450"}
if ($OutDevBox.Text -eq "iPad"){$BitRateBox.Text="2.5Mb";$OutResBox.Text="1024x576"}
if ($OutDevBox.Text -eq "iPhone"){$BitRateBox.Text="1.5Mb";$OutResBox.Text="480x270"}
if ($OutDevBox.Text -eq "iPod Classic"){$BitRateBox.Text=".8Mb";$OutResBox.Text="320x180"}
if ($OutDevBox.Text -eq "iPod Nano"){$BitRateBox.Text=".8Mb";$OutResBox.Text="320x180"}
if ($OutDevBox.Text -eq "iPod Touch"){$BitRateBox.Text="1.5Mb";$OutResBox.Text="480x270"}
if ($OutDevBox.Text -eq "Motorola Xoom"){$BitRateBox.Text="2.5Mb";$OutResBox.Text="1280x720"}
if ($OutDevBox.Text -eq "Palm Pixi"){$BitRateBox.Text=".8Mb";$OutResBox.Text="400x224"}
if ($OutDevBox.Text -eq "Samsung Galaxy S"){$BitRateBox.Text="1.5Mb";$OutResBox.Text="800x450"}
if ($OutDevBox.Text -eq "Samsung Galaxy Tab"){$BitRateBox.Text="1.5Mb";$OutResBox.Text="1024x576"}
if ($OutDevBox.Text -eq "Sony PlayStation 3"){$BitRateBox.Text="2.5Mb";$OutResBox.Text="1920x1080"}
if ($OutDevBox.Text -eq "Sony PSP"){$BitRateBox.Text="1.5Mb";$OutResBox.Text="480x270"}
if ($OutDevBox.Text -eq "Sony Xperia Arc"){$BitRateBox.Text="1.5Mb";$OutResBox.Text="854x480"}
if ($OutDevBox.Text -eq "Xbox 360"){$BitRateBox.Text="5.0Mb";$OutResBox.Text="1280x720"}
if ($OutDevBox.Text -eq "YouTube"){$BitRateBox.Text="3.0Mb";$OutResBox.Text="1280x720"}
if ($OutDevBox.Text -eq "Zune"){$BitRateBox.Text="1.5Mb";$OutResBox.Text="320x180"}
if ($OutDevBox.Text -eq "Zune HD"){$BitRateBox.Text="3.0Mb";$OutResBox.Text="1280x720"}
if ($OutDevBox.Text -eq "Custom Media Center"){$BitRateBox.Text="25.0Mb";$OutResBox.Text="1920x1080"}
}

function checkOverwrite
{
if ($OverWrBox.Checked -eq $True){Set-Variable -Name OvWr -Value "-w " -Scope 1;}
if ($OverWrBox.Checked -eq $False){Set-Variable -Name OvWr -Value "" -Scope 1;}
}

function chkForBatFile
{
$fileChk=Test-Path -Path $BatFile
if ($fileChk -eq $False){New-Item -ItemType file -Path $BatFile}
}

function SelectFolder($message='Select a folder', $path = 0)
{
$object = New-Object -comObject Shell.Application
$folder = $object.BrowseForFolder(0, $message, 0, $path)
Set-Variable -Name SelFolder -Value $folder.self.Path -Scope 1
}

function checkDevInFilename
{
if ($IncDevInFNBox.Checked -eq $True){Set-Variable -Name DevInFileName -Value $OutDevBox.Text -Scope 1}
}

function SetBat
{
setBitrate
setResolution
checkOverwrite
checkDevInFilename
$InputDir=$InPathBox.Text
$OutputDir=$OutPathBox.Text
$FilesFound = Get-ChildItem -Path $InputDir\* -Include *.M2V, *.MPG, *.VOB, *.AVI, *.TRP, *.TS, *.M2T, *.M2TS, *.MPEG, *.MTS, *.MOV, *.MP4, *.MKV, *.WMV -Name
Set-Variable -Name FilesFoundGlobal -Value $FilesFound -Scope 1
Set-Variable -Name AudGain -Value $AudGanBox.Text
Set-Variable -Name OutDev -Value $OutDevBox.Text
Get-ChildItem -Path $InputDir\* -Include *.M2V, *.MPG, *.VOB, *.AVI, *.TRP, *.TS, *.M2T, *.M2TS, *.MPEG, *.MTS, *.MOV, *.MP4, *.MKV, *.WMV -Name|
ForEach-Object {$SetArgs=" -i "+ """" +$InputDir+"\"+$_+""" " + $OvWr + "-res " + $OutRes + " -br " + $BitRateVal + " -ag " + $AudGain + " -outdev " + """" + $OutDev + """ " + """" + $OutputDir+"\"+$DevInFileName+$_+"""";
$FileRun="echo Currently Transcoding "+$_+" & ";
$Command=$FileRun+$ExePath+$SetArgs;
Add-Content -Path $BatFile -Value $Command}
Set-Variable -Name FilesAddedToBat -Value $True -Scope 1
}

function Show-MessageBox ($Title, $Message)
{
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
[Windows.Forms.MessageBox]::Show($Message, $Title, [Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Warning, [System.Windows.Forms.MessageBoxDefaultButton]::Button1, [System.Windows.Forms.MessageBoxOptions]::DefaultDesktopOnly) | Out-Null
}

function Show-InformationBox ($Title, $Message)
{
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
[Windows.Forms.MessageBox]::Show($Message, $Title, [Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information, [System.Windows.Forms.MessageBoxDefaultButton]::Button1, [System.Windows.Forms.MessageBoxOptions]::DefaultDesktopOnly) | Out-Null
}

function Show-YesNoBox ($Title, $Message)
{
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
$Result = [Windows.Forms.MessageBox]::Show($Message, $Title, [Windows.Forms.MessageBoxButtons]::YesNo, [System.Windows.Forms.MessageBoxIcon]::None, [System.Windows.Forms.MessageBoxDefaultButton]::Button1, [System.Windows.Forms.MessageBoxOptions]::DefaultDesktopOnly)
Set-Variable -Name MultiDevBat -Value $Result -Scope 1
}

#EndRegion Functions

#Region "Badaboom Powershell Batch Convert GUI"

#Region Initial Window
Show-YesNoBox "Badaboom Batch Check" "Will you be converting files for multiple devices?"
#EndRegion Initial Window

#Region Main Window
$objForm=New-Object System.Windows.Forms.Form
$objForm.Text="Badaboom Powershell Batch Convert"
$objForm.Size=New-Object System.Drawing.Size(725,340)
$objForm.StartPosition="CenterScreen"
$objForm.MaximizeBox=$False
$objForm.FormBorderStyle="FixedSingle"
#EndRegion Main Window

#Region Labels
addlabel "Badaboom Batch Convert" 11 Bold 30 20 350 22
addlabel "Input Path:" 9 Regular 20 (69 + 0) $DefLblXSiz $DefLblYSiz
addlabel "Output Path:" 9 Regular 20 (69 + 25) $DefLblXSiz $DefLblYSiz
addlabel "Output Device:" 9 Regular 20 (69 + 50) $DefLblXSiz $DefLblYSiz
addlabel "Output Resolution:" 9 Regular 20 (69 + 75) $DefLblXSiz $DefLblYSiz
addlabel "Bit Rate:" 9 Regular 20 (69 + 100) $DefLblXSiz $DefLblYSiz
addlabel "Audio Gain:" 9 Regular 20 (69 + 125) $DefLblXSiz $DefLblYSiz
addlabel "Overwrite Existing:" 9 Regular 20 (69 + 150) $DefLblXSiz $DefLblYSiz
addlabel "Inc Dev in Filename:" 9 Regular 20 (69 + 175) $DefLblXSiz $DefLblYSiz
#EndRegion Labels

#Region Data Fields

#Region Input Path Selection Box
$InPathBox=New-Object system.Windows.Forms.TextBox
$InPathBox.Location=New-Object system.Drawing.Size($DtaFldXpos,($DtaFldYpos + 0))
$InPathBox.Size=$DtaFldSiz
$InPathBox.Font=$DtaFldFnt
$InPathBox.Text=$InputDir
$objForm.Controls.Add($InPathBox)
#EndRegion Input Path Selection Box

#Region Output Path Selection Box
$OutPathBox=New-Object system.Windows.Forms.TextBox
$OutPathBox.Location=New-Object system.Drawing.Size($DtaFldXpos,($DtaFldYpos + 25))
$OutPathBox.Size=$DtaFldSiz
$OutPathBox.Font=$DtaFldFnt
$OutPathBox.MaxLength="10"
$OutPathBox.Text=$OutputDir
$objForm.Controls.Add($OutPathBox)
#EndRegion Output Path Selection Box

#Region Output Device Selection Box
$OutDevBox=New-Object system.Windows.Forms.ComboBox
$OutDevBox.Location=New-Object system.Drawing.Size($DtaFldXpos,($DtaFldYpos + 50))
$OutDevBox.Size=$DtaFldSiz2
$OutDevBox.Font=$DtaFldFnt
$OutDevBox.DropDownStyle="DropDownList"

[void] $OutDevBox.Items.Add("Xbox 360");[void] $OutDevBox.Items.Add("HTC Droid Incredible");[void] $OutDevBox.Items.Add("Custom Media Center");[void] $OutDevBox.Items.Add("Apple TV")
[void] $OutDevBox.Items.Add("BlackBerry Bold");[void] $OutDevBox.Items.Add("BlackBerry Torch");[void] $OutDevBox.Items.Add("HTC Droid Incredible");[void] $OutDevBox.Items.Add("HTC HD7")
[void] $OutDevBox.Items.Add("iPad");[void] $OutDevBox.Items.Add("iPhone");[void] $OutDevBox.Items.Add("iPod Classic");[void] $OutDevBox.Items.Add("iPod Nano")
[void] $OutDevBox.Items.Add("iPod Touch");[void] $OutDevBox.Items.Add("Motorola Xoom");[void] $OutDevBox.Items.Add("Palm Pixi");[void] $OutDevBox.Items.Add("Samsung Galaxy S")
[void] $OutDevBox.Items.Add("Samsung Galaxy Tab");[void] $OutDevBox.Items.Add("Sony PlayStation 3");[void] $OutDevBox.Items.Add("Sony PSP");[void] $OutDevBox.Items.Add("Sony Xperia Arc")
[void] $OutDevBox.Items.Add("Xbox 360");[void] $OutDevBox.Items.Add("YouTube");[void] $OutDevBox.Items.Add("Zune");[void] $OutDevBox.Items.Add("Zune HD");[void] $OutDevBox.Items.Add("Custom Media Center")

$OutDevBox.Text="Xbox 360"
$objForm.Controls.Add($OutDevBox)
#EndRegion Output Device Selection Box

#Region Output Resolution Box
$OutResBox=New-Object system.Windows.Forms.ComboBox
$OutResBox.Location=New-Object system.Drawing.Size($DtaFldXpos,($DtaFldYpos + 75))
$OutResBox.Size=$DtaFldSiz2
$OutResBox.Font=$DtaFldFnt
$OutResBox.DropDownStyle="DropDownList"

[void] $OutResBox.Items.Add("1280x720");[void] $OutResBox.Items.Add("800x450");[void] $OutResBox.Items.Add("854x480");[void] $OutResBox.Items.Add("1920x1080")
[void] $OutResBox.Items.Add("320x180");[void] $OutResBox.Items.Add("320x240");[void] $OutResBox.Items.Add("352x198");[void] $OutResBox.Items.Add("352x240")
[void] $OutResBox.Items.Add("400x224");[void] $OutResBox.Items.Add("400x320");[void] $OutResBox.Items.Add("400x240");[void] $OutResBox.Items.Add("400x360")
[void] $OutResBox.Items.Add("480x270");[void] $OutResBox.Items.Add("480x272");[void] $OutResBox.Items.Add("480x320");[void] $OutResBox.Items.Add("400x320")
[void] $OutResBox.Items.Add("480x360");[void] $OutResBox.Items.Add("400x320");[void] $OutResBox.Items.Add("640x360");[void] $OutResBox.Items.Add("640x480")
[void] $OutResBox.Items.Add("704x396");[void] $OutResBox.Items.Add("704x404");[void] $OutResBox.Items.Add("720x480");[void] $OutResBox.Items.Add("720x480")
[void] $OutResBox.Items.Add("720x576");[void] $OutResBox.Items.Add("800x450");[void] $OutResBox.Items.Add("800x480");[void] $OutResBox.Items.Add("800x600")
[void] $OutResBox.Items.Add("854x480");[void] $OutResBox.Items.Add("960x540");[void] $OutResBox.Items.Add("960x640");[void] $OutResBox.Items.Add("1024x576")
[void] $OutResBox.Items.Add("1024x600");[void] $OutResBox.Items.Add("1024x768");[void] $OutResBox.Items.Add("1280x720");[void] $OutResBox.Items.Add("1280x800")
[void] $OutResBox.Items.Add("1366x720");[void] $OutResBox.Items.Add("1440x810");[void] $OutResBox.Items.Add("1440x1080");[void] $OutResBox.Items.Add("1920x1080")

$OutResBox.Text="1280x720"
$objForm.Controls.Add($OutResBox)
#EndRegion Output Resolution Box

#Region Bit Rate Selection Box
$BitRateBox=New-Object system.Windows.Forms.ComboBox
$BitRateBox.Location=New-Object system.Drawing.Size($DtaFldXpos,($DtaFldYpos + 100))
$BitRateBox.Size=$DtaFldSiz2
$BitRateBox.Font=$DtaFldFnt
$BitRateBox.DropDownStyle="DropDownList"

[void] $BitRateBox.Items.Add(".5Mb");[void] $BitRateBox.Items.Add(".8Mb");[void] $BitRateBox.Items.Add("1.0Mb");[void] $BitRateBox.Items.Add("1.5Mb");[void] $BitRateBox.Items.Add("2.0Mb")
[void] $BitRateBox.Items.Add("2.5Mb");[void] $BitRateBox.Items.Add("3.0Mb");[void] $BitRateBox.Items.Add("3.5Mb");[void] $BitRateBox.Items.Add("4.0Mb");[void] $BitRateBox.Items.Add("4.5Mb")
[void] $BitRateBox.Items.Add("5.0Mb");[void] $BitRateBox.Items.Add("5.5Mb");[void] $BitRateBox.Items.Add("6.0Mb");[void] $BitRateBox.Items.Add("6.5Mb");[void] $BitRateBox.Items.Add("7.0Mb")
[void] $BitRateBox.Items.Add("7.5Mb");[void] $BitRateBox.Items.Add("8.0Mb");[void] $BitRateBox.Items.Add("8.5Mb");[void] $BitRateBox.Items.Add("9.0Mb");[void] $BitRateBox.Items.Add("9.5Mb")
[void] $BitRateBox.Items.Add("10.0Mb");[void] $BitRateBox.Items.Add("10.5Mb");[void] $BitRateBox.Items.Add("11.0Mb");[void] $BitRateBox.Items.Add("11.5Mb");[void] $BitRateBox.Items.Add("12.0Mb")
[void] $BitRateBox.Items.Add("12.5Mb");[void] $BitRateBox.Items.Add("13.0Mb");[void] $BitRateBox.Items.Add("13.5Mb");[void] $BitRateBox.Items.Add("14.0Mb");[void] $BitRateBox.Items.Add("14.5Mb")
[void] $BitRateBox.Items.Add("15.0Mb");[void] $BitRateBox.Items.Add("15.5Mb");[void] $BitRateBox.Items.Add("16.0Mb");[void] $BitRateBox.Items.Add("16.5Mb");[void] $BitRateBox.Items.Add("17.0Mb")
[void] $BitRateBox.Items.Add("17.5Mb");[void] $BitRateBox.Items.Add("18.0Mb");[void] $BitRateBox.Items.Add("18.5Mb");[void] $BitRateBox.Items.Add("19.0Mb");[void] $BitRateBox.Items.Add("19.5Mb")
[void] $BitRateBox.Items.Add("20.0Mb");[void] $BitRateBox.Items.Add("20.5Mb");[void] $BitRateBox.Items.Add("21.0Mb");[void] $BitRateBox.Items.Add("21.5Mb");[void] $BitRateBox.Items.Add("22.0Mb")
[void] $BitRateBox.Items.Add("22.5Mb");[void] $BitRateBox.Items.Add("23.0Mb");[void] $BitRateBox.Items.Add("23.5Mb");[void] $BitRateBox.Items.Add("24.0Mb");[void] $BitRateBox.Items.Add("24.5Mb")
[void] $BitRateBox.Items.Add("25.0Mb")

$BitRateBox.Text="5.0Mb"
$objForm.Controls.Add($BitRateBox)
#EndRegion Bit Rate Selection Box

#Region Audio Gain Selection Box
$AudGanBox=New-Object system.Windows.Forms.ComboBox
$AudGanBox.Location=New-Object system.Drawing.Size($DtaFldXpos,($DtaFldYpos + 125))
$AudGanBox.Size=$DtaFldSiz2
$AudGanBox.Font=$DtaFldFnt
$AudGanBox.DropDownStyle="DropDownList"

[void] $AudGanBox.Items.Add("6");[void] $AudGanBox.Items.Add("5");[void] $AudGanBox.Items.Add("4");[void] $AudGanBox.Items.Add("3");[void] $AudGanBox.Items.Add("2")
[void] $AudGanBox.Items.Add("1");[void] $AudGanBox.Items.Add("0");[void] $AudGanBox.Items.Add("-1");[void] $AudGanBox.Items.Add("-2");[void] $AudGanBox.Items.Add("-3")
[void] $AudGanBox.Items.Add("-4");[void] $AudGanBox.Items.Add("-5");[void] $AudGanBox.Items.Add("-6");[void] $AudGanBox.Items.Add("-7");[void] $AudGanBox.Items.Add("-8")
[void] $AudGanBox.Items.Add("-9");[void] $AudGanBox.Items.Add("-10");[void] $AudGanBox.Items.Add("-11");[void] $AudGanBox.Items.Add("-12");[void] $AudGanBox.Items.Add("-13")
[void] $AudGanBox.Items.Add("-14");[void] $AudGanBox.Items.Add("-15");[void] $AudGanBox.Items.Add("-16");[void] $AudGanBox.Items.Add("-17");[void] $AudGanBox.Items.Add("-18")
[void] $AudGanBox.Items.Add("-19");[void] $AudGanBox.Items.Add("-20")

$AudGanBox.Text="0"
$objForm.Controls.Add($AudGanBox)
#EndRegion Audio Gain Selection Box

#Region Overwrite Existing Output File Box
$OverWrBox=New-Object system.Windows.Forms.CheckBox
$OverWrBox.Location=New-Object system.Drawing.Size(($DtaFldXpos +2),($DtaFldYpos + 155))
$OverWrBox.Size=$DtaFldSiz
$OverWrBox.Font=$DtaFldFnt
$OverWrBox.Checked=$True
$objForm.Controls.Add($OverWrBox)
#EndRegion Overwrite Existing Output File Box

#Region Include Device Type in Filename Box
$IncDevInFNBox=New-Object system.Windows.Forms.CheckBox
$IncDevInFNBox.Location=New-Object system.Drawing.Size(($DtaFldXpos +2),($DtaFldYpos + 180))
$IncDevInFNBox.Size=$DtaFldSiz
$IncDevInFNBox.Font=$DtaFldFnt
if ($MultiDevBat -eq "Yes"){$IncDevInFNBox.Checked=$True;$IncDevInFNBox.Enabled=$false}
elseif ($MultiDevBat -eq "No"){$IncDevInFNBox.Checked=$False}
$objForm.Controls.Add($IncDevInFNBox)
#EndRegion Include Device Type in Filename Box

#EndRegion Data Fields

#Region Buttons

#Region Button Variables
$ButonFnt=New-Object System.Drawing.Font("Verdana",9)
$ButonFntSml=New-Object System.Drawing.Font("Verdana",7)
$ButonSiz=New-Object System.Drawing.Size(80,23)
$ButonSizSml=New-Object System.Drawing.Size(30,23)
$ButonSizLng=New-Object System.Drawing.Size(170,20)
$ButonYpos=275
#EndRegion Button Variables

#Region Run Button
$RunButton=New-Object System.Windows.Forms.Button
$RunButton.Location=New-Object System.Drawing.Size(110,$ButonYpos)
$RunButton.Size=$ButonSiz
$RunButton.Font=$ButonFnt
$RunButton.Text="Run"
$RunButton.Add_Click(
{
chkForBatFile
if ($MultiDevBat -eq "No")
{
Set-Content -Path $BatFile -Value $BatNote;
SetBat
$objForm.Close()
#Write-Host Run "-" $BatFile
[Diagnostics.Process]::Start($BatFile)
}
elseif (($MultiDevBat -eq "Yes") -and ($FilesAddedToBat -eq $False))
{
#Write-Host $FilesAddedToBat
Show-MessageBox "Warning Message" "You Must First Add Files to the Batch Job"
}
elseif (($MultiDevBat -eq "Yes") -and ($FilesAddedToBat -eq $True))
{
$objForm.Close()
#Write-Host "Run -" $BatFile
[Diagnostics.Process]::Start($BatFile)
}
})
$objForm.Controls.Add($RunButton)
#EndRegion Run Button

#Region Add Run For Additional Device Button
$AddToBatBtn=New-Object System.Windows.Forms.Button
$AddToBatBtn.Location=New-Object System.Drawing.Size(200,$ButonYpos)
$AddToBatBtn.Size=$ButonSiz
$AddToBatBtn.Font=$ButonFnt
$AddToBatBtn.Text="Add to Bat"
if ($MultiDevBat -eq "No"){$AddToBatBtn.Enabled=$false}
$AddToBatBtn.Add_Click(
{
if ($FilesAddedToBat -eq $False)
{
Set-Content -Path $BatFile -Value $BatNote;
SetBat
if ($FilesFoundGlobal.Count -eq $null){$FilesAddMsg="1 Movie File Has Been Added to the Batch"}
else {$FilesAddMsg=[string]$FilesFoundGlobal.Count + " Movie Files Have Been Added to the Batch"}
Show-InformationBox "Files Added To Batch" $FilesAddMsg
}
elseif ($FilesAddedToBat -eq $True)
{
SetBat
if ($FilesFoundGlobal.Count -eq $null){$FilesAddMsg="1 More Movie File Has Been Added to the Batch"}
else {$FilesAddMsg=[string]$FilesFoundGlobal.Count + " More Movie Files Have Been Added to the Batch"}
Show-InformationBox "Files Added To Batch" $FilesAddMsg
}
elseif ($MultiDevBat -eq "Yes")
{
Show-MessageBox "Warning Message" "Need to include Device Type in Filename"
}
})
$objForm.Controls.Add($AddToBatBtn)
#EndRegion Cancel Button

#Region Cancel Button
$CancelButton=New-Object System.Windows.Forms.Button
$CancelButton.Location=New-Object System.Drawing.Size(290,$ButonYpos)
$CancelButton.Size=$ButonSiz
$CancelButton.Font=$ButonFnt
$CancelButton.Text="Cancel"
$CancelButton.Add_Click(
{
$objForm.Close();
})
$objForm.Controls.Add($CancelButton)
#EndRegion Cancel Button

#Region Input Folder Select Button
$InFldButton=New-Object System.Windows.Forms.Button
$InFldButton.Location=New-Object System.Drawing.Size(665,65)
$InFldButton.Size=$ButonSizSml
$InFldButton.Font=$ButonFnt
$InFldButton.Text="..."
$InFldButton.Add_Click(
{
SelectFolder -mess 'Select the Desired Input Folder'
if ($SelFolder -ne $null)
{
$InPathBox.Text=$SelFolder
}
})
$objForm.Controls.Add($InFldButton)
#EndRegion Input Folder Select Button

#Region Output Folder Select Button
$OutFldButton=New-Object System.Windows.Forms.Button
$OutFldButton.Location=New-Object System.Drawing.Size(665,90)
$OutFldButton.Size=$ButonSizSml
$OutFldButton.Font=$ButonFnt
$OutFldButton.Text="..."
$OutFldButton.Add_Click(
{
SelectFolder -mess 'Select the Desired Output Folder'
if ($SelFolder -ne $null)
{
$OutPathBox.Text=$SelFolder
}
})
$objForm.Controls.Add($OutFldButton)
#EndRegion Output Folder Select Button

#Region Set Res & BR to Dev Def Button
$SetDevDefButn=New-Object System.Windows.Forms.Button
$SetDevDefButn.Location=New-Object System.Drawing.Size(320,118)
$SetDevDefButn.Size=$ButonSizLng
$SetDevDefButn.Font=$ButonFntSml
$SetDevDefButn.Text="Set Res and BR to Dev Defaults"
$SetDevDefButn.Add_Click(
{
SetDeviceDefaults
})
$objForm.Controls.Add($SetDevDefButn)
#EndRegion Set Res & BR to Dev Def Button

#EndRegion Buttons

[void] $objForm.ShowDialog()

#EndRegion "Badaboom Powershell Batch Convert GUI"