Quantcast
Channel: Total Commander
Viewing all articles
Browse latest Browse all 18767

Eng :: RE: How to put a FOR loop command on the button bar?

$
0
0
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"}




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 Embarassed


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


Viewing all articles
Browse latest Browse all 18767

Trending Articles