DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Remove empty lines  (Read 9,099 times)

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Remove empty lines
« on: July 01, 2013, 12:24 AM »
Remove empty lines in a txt file
I know the only solution : techmechanics

http://textmechanic.com/Remove-Empty-Lines.html

But I would like a free desktop option. Better is portable.
Best Regards

erikts

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 227
Re: Remove empty lines
« Reply #1 on: July 01, 2013, 12:35 AM »
I use Notepad ++, click menu Edit, select Line Operations, then select:
  • Remove Empty Lines, or
  • Remove Empty Lines (Containing blank characters)

Also you can use Notepad2 (portable version is available, ):
  • Select the text
  • Press Alt+R (or via menu Edit|Block|Remove Blank Lines)
« Last Edit: July 01, 2013, 01:38 AM by erikts »

cmpm

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 2,026
Re: Remove empty lines
« Reply #2 on: July 01, 2013, 12:50 AM »
You may want to try Dolphin Text Editor Menu.
It runs in the tray, triggered via hotkey.

http://www.animal-software.com/index.php

x16wda

  • what am I doing in this handbasket?
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
    • Participated in NANY Challenge Once
Re: Remove empty lines
« Reply #3 on: July 01, 2013, 01:06 AM »
You may want to try Dolphin Text Editor Menu.
It runs in the tray, triggered via hotkey.

http://www.animal-software.com/index.php

I'll second that.  Very convenient.
vi vi vi - editor of the beast

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: Remove empty lines
« Reply #4 on: July 01, 2013, 01:25 AM »
My Clipboard Help and Spell program will happily take the text selected in any program and do manipulations including removing blank lines, and then paste it back (replacing the original text), and let you set up a hotkey to do this.
« Last Edit: July 01, 2013, 01:31 AM by mouser »

rsatrioadi

  • Participant
  • Joined in 2009
  • *
  • Posts: 58
    • Linux User
Re: Remove empty lines
« Reply #5 on: July 01, 2013, 02:34 AM »
Use sed? :P

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Re: Remove empty lines
« Reply #6 on: July 01, 2013, 02:40 AM »
:-*
I have notepad++
Running to do

Edvard

  • Coding Snacks Author
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 3,027
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Linux User
Re: Remove empty lines
« Reply #7 on: July 01, 2013, 07:05 AM »
Download this:
http://gnuwin32.sourceforge.net/packages/sed.htm

Put it in somewhere in your %PATH%, unless the installer does it for you (haven't tested).

Then do this:
Code
sed -i '/^$/d' filewithblanklines.txt

With a little registry magic, you can even add it as a context menu item.  Look here:
http://www.howtogeek.com/howto/windows-vista/add-any-application-to-the-desktop-right-click-menu-in-vista/

My registry knowledge is a bit rusty, or else I'd tell you exactly how with a .reg file so it only opens up when you right-click TXT files.
Any takers?
All children left unattended will be given a mocha and a puppy.

AbteriX

  • Member #520
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,150
Re: Remove empty lines mit plain old DOS commands
« Reply #8 on: July 01, 2013, 10:59 AM »
Remove empty lines in a txt file

See file content:
Code: (generic)
C:\>TYPE input.txt



Filter for lines not (/V) being empty (^$):
Code: (generic)
C:\>TYPE input.txt | findstr /V "^$"
(piping (|) the output of type to the input of findstr)
(for empty lines possible containing whitespace use: "^\s*$")



Filter and write to new file:
Code: (generic)
C:\>TYPE input.txt | findstr /V "^$" > output.txt


More about at http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/findstr.mspx


.
Greetings, Stefan.

Original address: https://www.donationcoder.com/forum/index.php?topic=35312.0