Author: Stefan2
Subject: PowerShell:
Posted: Tue Apr 12, 2016 2:53 pm (GMT -6)
Little late for launch break, isn't it?![Very Happy]()
Good work.
Would that more simple code also work?:
$LastLine = (gc $filePath )[-1]
IF( $LastLine.Trim() -match "^$" ){"empty line"}else{"text line"}
I hope you don't mind![Embarassed]()
_________________
MfG, Stefan
WinXP-10, 32+64-Bit
Am Anfang war das Wort... Darum: Wehret den Anfängen. Kein Viertes Reich! - (☪ oe ✡ is ) = ☮
Subject: PowerShell:
Posted: Tue Apr 12, 2016 2:53 pm (GMT -6)
Little late for launch break, isn't it?

Good work.
Would that more simple code also work?:
$LastLine = (gc $filePath )[-1]
IF( $LastLine.Trim() -match "^$" ){"empty line"}else{"text line"}
Code: |
if ( (gc $filePath )[-1].Trim() -match "^$" ) { #"empty line" Add-Content -Path $filePath -Value "`r`n$fileName" } else { #"text line" Add-Content -Path $filePath -Value "`r`n`r`n$fileName" } |
I hope you don't mind

_________________
MfG, Stefan
WinXP-10, 32+64-Bit
Am Anfang war das Wort... Darum: Wehret den Anfängen. Kein Viertes Reich! - (☪ oe ✡ is ) = ☮