magento
asked on
Powershell script fix
Hi ,
EE experts helped on my question.
https://www.experts-exchange.com/questions/28396033/Windows-batch-script.html
In columnB i have all lines of a txt file except first line.
The original txt file has line breaks,
The new csv file do not. It's just one long piece of text . Can you please advice whether we can fix it?
Thanks
EE experts helped on my question.
https://www.experts-exchange.com/questions/28396033/Windows-batch-script.html
In columnB i have all lines of a txt file except first line.
The original txt file has line breaks,
The new csv file do not. It's just one long piece of text . Can you please advice whether we can fix it?
get-childitem 'C:\EE\FOLDER\' |
? { $_.PsIsContainer } | % {
$folder = $_.FullName
get-childitem $folder -Filter *.txt | % {
$content=Get-Content $_.FullName
$colA = $content | select -first 1
$colB = $content | Select -Skip 1
if ($colB[0].Length -lt 10 -and $colB[0] -match '\w+\.[XVI]+\.\d+')
{
$colA += ' ' + $colB[0]
$colB = $colB[(-$colB.Count+1)..-1]
}
New-Object PsObject -Property @{
ColumnA= $colA -replace 'AuthorName', ''
ColumnB = $colB -join ' ' }
} | export-csv "C:\EE\FOLDER\$(Split-Path -leaf $folder).csv" -NoTypeInformation -Encoding UTF8
}
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tried double quote and it seems working, let me check all files and let you know.
ColumnB = $colB -join "`n" }
ASKER
Thanks for the pointer .
Oh, sorry, of course you need to use double quotes instead of single quotes. Stupid beginner's mistake.
ASKER
I am afraid , if you are beginner ..What am i ???
I'm not a beginner for sure, but still making mistakes like one ;-). This is one "habit" I don't get out of my way.
ASKER
I know for sure you are not a beginner . Getting rank of Prodigy is not possible without great skills. Thanks for your help.
ASKER
I tried the above but get the value instead .. I used backtip n
eg: Dr. Dominik Waldvogel`nRaub`n2012