#file:sra-split.ps1
#Author:Marinaldo de Jesus
#date:2016-01-06
#Use:1) Ordenar o arquivo de saída do sistema Senior
# 2) Dividir o arquivo gerando os dados por Filial
# 3) Separar em Canais Válidos
#Define o Nome do Arquivo Gerado pelo Senior
Function sra-split {
[CmdletBinding(
SupportsShouldProcess=$True,
ConfirmImpact="Low"
)
]
Param(
[Parameter(Mandatory=$True,Position=1)]
[string]$filePath="sra.txt"
)
$txtSRA=$filePath
$fName=[System.IO.Path]::GetFileNameWithoutExtension($txtSRA)
$txtSort=$txtSRA.Replace($fName,"$($fName)-sort")
#Obtém o Conteúdo do Arquivo
$sortSRA=Get-Content $txtSRA
#Ordena as Informações
$sortSRA | sort-object | Out-File -FilePath $txtSort -Encoding ascii -Force
#Define o Path para a Gravação dos Arquivos
$pathSRA=".\split\sra\"
#Obtém o Conteúdo do Arquivo Ordenado
$sortSRA=Get-Content $txtSort
#Força a Criação do Diretório Split a partir de .\
New-Item -path $pathSRA -type directory -Force
#Remove qualquer item existente em .\split
Remove-Item -Path "$pathSRA\*"
#Define a HashTable com os Canais
$Canais=@{
SRA_0="SRA_0";
SRA_1="SRA_1";
SRA_2="SRA_2";
SRA_3="SRA_3";
SRA_4="SRA_4";
SRA_5="SRA_5"
}
#Define o Array com as Filiais
$Filiais=@("0101","0102","0103","0104","0105","9801")
#Define bgColor
$bgColor="Black"
#Define fgColor
$fgColor="DarkRed"
#Define variável para controle de alteração da cor
$bChgColor=$True
#Define separador
$cSep="--------------------------------------------------------------------------"
$FilePath=""
Write-Host $cSep -foregroundcolor yellow -backgroundcolor $bgColor
#Lê o conteúdo do arquivo e gera um novo arquivo por Filial
foreach ($Filial in $Filiais) {
$key=""
$lKey=""
#Processa para cada CANAL
foreach ($Canal in $Canais.Values | Sort-Object )
{
Write-Host $Filial,$Canal
Write-Host $cSep -foregroundcolor yellow -backgroundcolor $bgColor
#Gera o arquivo por Filial e Canal
$sortSRA | ? {$_.Substring(0,4).Contains($Filial) -and $_.Substring(12,5).Contains($Canal) } | ? {
#Obtém a chave para pesquisa
$key=$_.Substring(0,17)
#Verifica se é igual a última chave utilizada
if ($key -eq $lKey){
#Define o arquivo para dados duplicados
$FilePath="$($pathSRA)dupl-sra-$($Filial)-$($Canal).txt"
} else {
#Define o arquivo para dados OK
$FilePath="$($pathSRA)sra-$($Filial)-$($Canal).txt"
}
#Grava os Dados no novo arquivo
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
#Salva a última chave utilizada
$lKey=$key
}
#Obtem o conteúdo para o CANAL
$FilePath="$($pathSRA)sra-$($Filial)-$($Canais[$Canal]).txt"
[System.Collections.ArrayList]$tmp=(Get-Content $FilePath | Where-Object {$_.Substring(12,5).Contains($Canais[$Canal])})
Set-Variable -Name "t_$Canal" -Value $tmp
#Remove o Arquivo de Trabalho
Remove-Item $FilePath -Force
}
#Processa a partir do CANAL SRA_0
($t_sra_0) | Foreach-Object {$index=0 }{
Try
{
$key=$t_sra_0.Item($index).Substring(4,8)
if ($sra_1=$t_sra_1 | Where-Object {$_.Substring(4,8).Contains($key)})
{
if ($sra_2=$t_sra_2 | Where-Object {$_.Substring(4,8).Contains($key)})
{
if ($sra_3=$t_sra_3 | Where-Object {$_.Substring(4,8).Contains($key)})
{
if ($sra_4=$t_sra_4 | Where-Object {$_.Substring(4,8).Contains($key)})
{
if ($sra_5=$t_sra_5 | Where-Object {$_.Substring(4,8).Contains($key)})
{
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_1 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_3 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_4 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_5 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-1-2-3-4-5.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_1 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_3 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_4 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_5 -FilePath $FilePath -Encoding ascii -Append
$t_sra_1.Remove($sra_1)
$t_sra_2.Remove($sra_2)
$t_sra_3.Remove($sra_3)
$t_sra_4.Remove($sra_4)
$t_sra_5.Remove($sra_5)
}
else {
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_1 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_3 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_4 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-1-2-3-4.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_1 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_3 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_4 -FilePath $FilePath -Encoding ascii -Append
$t_sra_1.Remove($sra_1)
$t_sra_2.Remove($sra_2)
$t_sra_3.Remove($sra_3)
$t_sra_4.Remove($sra_4)
}
}
elseif ($sra_5=$t_sra_5 | Where-Object {$_.Substring(4,8).Contains($key)})
{
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_1 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_3 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_5 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-1-2-3-5.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_1 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_3 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_5 -FilePath $FilePath -Encoding ascii -Append
$t_sra_1.Remove($sra_1)
$t_sra_2.Remove($sra_2)
$t_sra_3.Remove($sra_3)
$t_sra_5.Remove($sra_5)
}
else {
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_1 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_3 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-1-2-3.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_1 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_3 -FilePath $FilePath -Encoding ascii -Append
$t_sra_1.Remove($sra_1)
$t_sra_2.Remove($sra_2)
$t_sra_3.Remove($sra_3)
}
}
elseif ($sra_4=$t_sra_4 | Where-Object {$_.Substring(4,8).Contains($key)})
{
if ($sra_5=$t_sra_5 | Where-Object {$_.Substring(4,8).Contains($key)})
{
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_1 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_4 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_5 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-1-2-4-5.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_1 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_4 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_5 -FilePath $FilePath -Encoding ascii -Append
$t_sra_1.Remove($sra_1)
$t_sra_2.Remove($sra_2)
$t_sra_4.Remove($sra_4)
$t_sra_5.Remove($sra_5)
}
}
elseif ($sra_5=$t_sra_5 | Where-Object {$_.Substring(4,8).Contains($key)})
{
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_1 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_5 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-1-2-5.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_1 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_5 -FilePath $FilePath -Encoding ascii -Append
$t_sra_1.Remove($sra_1)
$t_sra_2.Remove($sra_2)
$t_sra_5.Remove($sra_5)
}
else {
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_1 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-1-2.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_1 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
$t_sra_1.Remove($sra_1)
$t_sra_2.Remove($sra_2)
}
}
else {
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_1 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-1.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_1 -FilePath $FilePath -Encoding ascii -Append
$t_sra_1.Remove($sra_1)
}
}
elseif ($sra_2=$t_sra_2 | Where-Object {$_.Substring(4,8).Contains($key)})
{
if ($sra_3=$t_sra_3 | Where-Object {$_.Substring(4,8).Contains($key)})
{
if ($sra_4=$t_sra_4 | Where-Object {$_.Substring(4,8).Contains($key)})
{
if ($sra_5=$t_sra_5 | Where-Object {$_.Substring(4,8).Contains($key)})
{
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_3 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_4 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_5 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-2-3-4-5.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_3 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_4 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_5 -FilePath $FilePath -Encoding ascii -Append
$t_sra_2.Remove($sra_2)
$t_sra_3.Remove($sra_3)
$t_sra_4.Remove($sra_4)
$t_sra_5.Remove($sra_5)
}
else {
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_3 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_4 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-2-3-4.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_3 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_4 -FilePath $FilePath -Encoding ascii -Append
$t_sra_2.Remove($sra_2)
$t_sra_3.Remove($sra_3)
$t_sra_4.Remove($sra_4)
}
}
elseif ($sra_4=$t_sra_4 | Where-Object {$_.Substring(4,8).Contains($key)})
{
if ($sra_5=$t_sra_5 | Where-Object {$_.Substring(4,8).Contains($key)})
{
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_4 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_5 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-2-4-5.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_4 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_5 -FilePath $FilePath -Encoding ascii -Append
$t_sra_2.Remove($sra_2)
$t_sra_4.Remove($sra_4)
$t_sra_5.Remove($sra_5)
}
}
elseif ($sra_5=$t_sra_5 | Where-Object {$_.Substring(4,8).Contains($key)})
{
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_5 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-2-5.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_5 -FilePath $FilePath -Encoding ascii -Append
$t_sra_2.Remove($sra_2)
$t_sra_5.Remove($sra_5)
}
else {
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_3 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-2-3.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_3 -FilePath $FilePath -Encoding ascii -Append
$t_sra_2.Remove($sra_2)
$t_sra_3.Remove($sra_3)
}
}
elseif ($sra_4=$t_sra_4 | Where-Object {$_.Substring(4,8).Contains($key)})
{
if ($sra_5=$t_sra_5 | Where-Object {$_.Substring(4,8).Contains($key)})
{
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_4 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_5 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-2-4-5.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_4 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_5 -FilePath $FilePath -Encoding ascii -Append
$t_sra_2.Remove($sra_2)
$t_sra_4.Remove($sra_4)
$t_sra_5.Remove($sra_5)
}
}
elseif ($sra_5=$t_sra_5 | Where-Object {$_.Substring(4,8).Contains($key)})
{
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_5 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-2-5.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_5 -FilePath $FilePath -Encoding ascii -Append
$t_sra_2.Remove($sra_2)
$t_sra_5.Remove($sra_5)
}
else {
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_2 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-2.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_2 -FilePath $FilePath -Encoding ascii -Append
$t_sra_2.Remove($sra_2)
}
}
elseif ($sra_3=$t_sra_3 | Where-Object {$_.Substring(4,8).Contains($key)})
{
if ($sra_4=$t_sra_4 | Where-Object {$_.Substring(4,8).Contains($key)})
{
if ($sra_5=$t_sra_5 | Where-Object {$_.Substring(4,8).Contains($key)})
{
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_3 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_4 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_5 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-3-4-5.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_3 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_4 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_5 -FilePath $FilePath -Encoding ascii -Append
$t_sra_3.Remove($sra_3)
$t_sra_4.Remove($sra_4)
$t_sra_5.Remove($sra_5)
}
else {
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_3 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_4 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-3-4.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_3 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_4 -FilePath $FilePath -Encoding ascii -Append
$t_sra_3.Remove($sra_3)
$t_sra_4.Remove($sra_4)
}
}
elseif ($sra_5=$t_sra_5 | Where-Object {$_.Substring(4,8).Contains($key)})
{
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_3 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_5 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-3-5.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_3 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_5 -FilePath $FilePath -Encoding ascii -Append
$t_sra_3.Remove($sra_3)
$t_sra_5.Remove($sra_5)
}
else {
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_3 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-3.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_3 -FilePath $FilePath -Encoding ascii -Append
$t_sra_3.Remove($sra_3)
}
}
elseif ($sra_4=$t_sra_4 | Where-Object {$_.Substring(4,8).Contains($key)})
{
if ($sra_5=$t_sra_5 | Where-Object {$_.Substring(4,8).Contains($key)})
{
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_4 -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_5 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-4-5.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_4 -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_5 -FilePath $FilePath -Encoding ascii -Append
$t_sra_4.Remove($sra_4)
$t_sra_5.Remove($sra_5)
}
else {
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_4 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-4.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_4 -FilePath $FilePath -Encoding ascii -Append
$t_sra_4.Remove($sra_4)
}
}
elseif ($sra_5=$t_sra_5 | Where-Object {$_.Substring(4,8).Contains($key)})
{
Write-Host $_ -foregroundcolor $fgColor -backgroundcolor $bgColor
Write-Host $sra_5 -foregroundcolor $fgColor -backgroundcolor $bgColor
$FilePath="$($pathSRA)sra-$($Filial)-Channels-0-5.txt"
Out-File -inputobject $_ -FilePath $FilePath -Encoding ascii -Append
Out-File -inputobject $sra_5 -FilePath $FilePath -Encoding ascii -Append
$t_sra_5.Remove($sra_5)
}
}
Catch
{
Write-Host $_.Exception.Message -foregroundcolor red -backgroundcolor yellow
}
Finally
{
#...
}
$index++
if ($bChgColor) {
$fgColor="White"
}
else {
$fgColor="DarkRed"
}
$bChgColor= -not($bChgColor)
Write-Host $cSep -foregroundcolor yellow -backgroundcolor $bgColor
}
}
}
sra-split "sra.txt"
Comentários
Postar um comentário