I returned to work on my old script and wanted to tackle a minor issue I have. As the title says I would like to replace double Carriage Returns and Line Feeds with single Carriage Returns and Line Feeds in specific txt files to remove empty lines. I want to automate this since it’s not needed for every part of the final txt file but only smaller sections.
Here is what I currently do:
(
ECHO ================================
ECHO Printers
WMIC printerconfig get Name
) | More > Printers.txt
The output is always something like this:
================================
Printers
Printer-01
Printer-02
Printer-03
etc. etc.
What I would like to do is to replace those double Carriage Returns and Line Feeds from the text file.
I was thinking of something like:
TYPE Printers.txt | Replace "Carriage Return Line Feed Carriage Return and Line Feed" by "Carriage Return and Line Feed" > Printers2.txt
I probably have the wrong command but to be honest the last time I actively worked on this script was years ago. And before reworking it for PowerShell I would like to work out a few kinks in case I need to use the bat file.