Function Get-FileName($initialDirectory)
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.initialDirectory = $initialDirectory
$OpenFileDialog.filter = "CSV (*.csv)| *.csv"
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.filename
}
Function Set-FileName()
{
Param (
[string]$InitialDirectory,
[string]$FileName
)
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog
$SaveFileDialog.initialDirectory = $InitialDirectory
$SaveFileDialog.FileName = $FileName
$SaveFileDialog.filter = "PSV (*.psv)| *.psv"
$SaveFileDialog.ShowDialog() | Out-Null
$SaveFileDialog.FileName
}
$InputFile = Get-FileName($env:userprofile)
$OutputFile = Set-FileName -InitialDirectory (Get-Item $InputFile).Directory -FileName (Get-Item $InputFile).Basename
#Converting CSV from OpenTx to PSV File for TTSAutomate
$Content = Get-Content $InputFile -Encoding UTF8 | ForEach {$_.replace('.wav', '').replace(';', '|').replace('ü','ue').replace('Ü','ue').replace('ä', 'ae').replace('Ä', 'ae').replace('Ö','oe').replace('ö','oe').replace('ß', 'ss')} | Set-Content($OutputFile)