26. März 2015 11:27
function SplitAlternatingLines
{
$lines = Get-Content C:\Temp\DEUFRA_Translation_UTF8.txt | Measure-Object –Line
$Nooflines = $lines.Lines
write-host "File has $Nooflines lines"
IF (Test-Path C:\Temp\evenlines.txt) {Remove-Item C:\Temp\evenlines.txt}
IF (Test-Path C:\Temp\unevenlines.txt) {Remove-Item C:\Temp\unevenlines.txt}
for ($i = 0; $i -le $lines.Lines; $i++)
{
$Currline = (Get-Content C:\Temp\DEUFRA_Translation_UTF8.txt)[$i]
if ($i%10 -eq 0) {Write-Host "Splitting line $i of $Nooflines"}
if (($i%2 -eq 0) -or ($i -eq 0))
{out-file C:\Temp\evenlines.txt -inputobject $Currline -force -append -Width 500 -Encoding utf8}
else
{out-file C:\Temp\unevenlines.txt -inputobject $Currline -force -append -Width 500 -Encoding utf8}
}
}
function SplitAlternatingLines2
{
$lines = Get-Content $args | Measure-Object –Line
$Nooflines = $lines.Lines
write-host "File has $Nooflines lines"
IF (Test-Path C:\Temp\evenlines.txt) {Remove-Item C:\Temp\evenlines.txt}
IF (Test-Path C:\Temp\unevenlines.txt) {Remove-Item C:\Temp\unevenlines.txt}
for ($i = 0; $i -le $lines.Lines; $i++)
{
$Currline = (Get-Content $args)[$i]
if ($i%10 -eq 0) {Write-Host "Splitting line $i of $Nooflines"}
if (($i%2 -eq 0) -or ($i -eq 0))
{out-file C:\Temp\evenlines.txt -inputobject $Currline -force -append -Width 500 -Encoding utf8}
else
{out-file C:\Temp\unevenlines.txt -inputobject $Currline -force -append -Width 500 -Encoding utf8}
}
}
31. März 2015 18:02