topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 3:17 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Remove empty lines  (Read 5974 times)

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Remove empty lines
« on: June 30, 2013, 07:24 PM »
Remove empty lines in a txt file
I know the only solution : techmechanics

http://textmechanic....ove-Empty-Lines.html

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

erikts

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 224
    • View Profile
    • Donate to Member
Re: Remove empty lines
« Reply #1 on: June 30, 2013, 07:35 PM »
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: June 30, 2013, 08:38 PM by erikts, Reason: Add Notepad2 »

cmpm

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 2,026
    • View Profile
    • Donate to Member
Re: Remove empty lines
« Reply #2 on: June 30, 2013, 07:50 PM »
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

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
  • what am I doing in this handbasket?
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Remove empty lines
« Reply #3 on: June 30, 2013, 08:06 PM »
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,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Remove empty lines
« Reply #4 on: June 30, 2013, 08:25 PM »
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: June 30, 2013, 08:31 PM by mouser »

rsatrioadi

  • Participant
  • Joined in 2009
  • *
  • Posts: 58
    • View Profile
    • Donate to Member
Re: Remove empty lines
« Reply #5 on: June 30, 2013, 09:34 PM »
Use sed? :P

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Remove empty lines
« Reply #6 on: June 30, 2013, 09:40 PM »
 :-*
I have notepad++
Running to do

Edvard

  • Coding Snacks Author
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 3,017
    • View Profile
    • Donate to Member
Re: Remove empty lines
« Reply #7 on: July 01, 2013, 02:05 AM »
Download this:
http://gnuwin32.sour...net/packages/sed.htm

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

Then do this:
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...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?

AbteriX

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,149
    • View Profile
    • Donate to Member
Re: Remove empty lines mit plain old DOS commands
« Reply #8 on: July 01, 2013, 05:59 AM »
Remove empty lines in a txt file

See file content:
Code: Text [Select]
  1. C:\>TYPE input.txt



Filter for lines not (/V) being empty (^$):
Code: Text [Select]
  1. 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: Text [Select]
  1. C:\>TYPE input.txt | findstr /V "^$" > output.txt


More about at http://www.microsoft...s/en-us/findstr.mspx


.