expirat001
expirat001

Reputation: 2195

Replace dots by carriage return with Powershell

I have got a file txt which contains music lyrics.

I want to replace all dots by a carriage return to have something more readable.

Thanks in advance.

Upvotes: 2

Views: 8274

Answers (2)

Andy Arismendi
Andy Arismendi

Reputation: 52587

Easy enough:

Get-Content C:\Imagine_Lyrics.txt | % {$_.Replace('.', "`n")} | Out-File C:\Imagine_Lyrics2.txt -Encoding ASCII

Upvotes: 2

mjolinor
mjolinor

Reputation: 68273

(get-content file.txt) -replace '\.',"`n" | out-file newfile.txt

The -replace operater uses a regex match, so you need to escape the dot to make it match a literal dot. Otherwise it will replace every character in the file.

Upvotes: 4

Related Questions