ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Delete lines in a txt files according rules

<< < (3/4) > >>

Contro:
Welcome to the site, Narny!
Contro -- the nice thing about Narny's solution is you can modify and extend it to do other things later.  Since you frequently need to do text manipulation, why not invest some time and learn a little perl so you can write your own scripts for such things?
-mouser (July 02, 2014, 10:25 AM)
--- End quote ---

Understood Mouser.
Welcome Narny!

Best Regards
 :-*

Contro:
Delete lines in a txt file according rules
By example :
with a script with a hotkey or similar delete in an open txt file the pairs lines.
Or delete all lines except the multiples of 5.-Contro (July 02, 2014, 05:41 AM)
--- End quote ---



Didn't I already write you a tool to do this?

https://www.donationcoder.com/forum/index.php?topic=36898.0
-skwire (July 02, 2014, 11:23 AM)
--- End quote ---

Ejem. Sure. But remember i don't remember very well.....
I solved this problem yesterday with pspad and a macro consisting - in that particular case - in delete navigating the lines 2, 3, 4 from the first line. Execute one. Then execute again. Or finally executing the macro x times.

But Mouser is right . I have to document the phrases to find quickly answers. Or program by myself. But the last option..... Aarrrgghhhhh.
I would like to have a powerful mind !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 :P

Contro:
@mouser: Thanks. Long-time user of FARR.

@Contro: I can try to make it more enticing for you!

Download and install Perl. It plonks itself into a folder somewhere and updates the %path%, I think. I don't think it touches the registry. You can just leave it there and forget it and never use it for anything else. All it costs you is ~340 MB of disk space.

Open a text editor, and type (or copy/paste) the following line, saving as "DelExcept.bat"

for %%f in (%2) do perl -i.bak -ne "print unless $. %% %1" "%%f"

Now, from a command line in the folder you want to delete things, type:

DelExcept 5 MyFile.txt

It'll delete all lines except every 5th in MyFile.txt

DelExcept 3 *.txt

which will delete all lines except every 3rd in all files in the folder with .txt extension.

It will take a copy of the original files first, adding .bak to the original name and extension.

I haven't read any of your previous posts, but if you're doing text processing and haven't discovered Perl then you're missing out big time! It'll repay every minute you invest 100 times over. But you can use batch file without having to learn anything new - it'll still do the job.

-narny (July 02, 2014, 11:43 AM)
--- End quote ---

Ejem. I must try this to correspond you.
I will inform you of the answers and keep this url to study

Best Regards

Contro:
Delete lines in a txt file according rules
By example :
with a script with a hotkey or similar delete in an open txt file the pairs lines.
Or delete all lines except the multiples of 5.-Contro (July 02, 2014, 05:41 AM)
--- End quote ---

Didn't I already write you a tool to do this?

https://www.donationcoder.com/forum/index.php?topic=36898.0
-skwire (July 02, 2014, 11:23 AM)
--- End quote ---

Skwire i have to apologyze.

I am studying phrases to find quickly my rememberings.
I put some post in the forum about this.
And other solution is reindexing in the background to follow any string too.
I am trying.
So forgive me.
Your program is very nice and a need to remember for the next time.

narny:
And other solution is reindexing in the background to follow any string too.
-Contro (July 04, 2014, 08:18 AM)
--- End quote ---

Google indexes every word in the background!
You can restrict the search to donationcoder's forum like so:

delete lines site:donationcoder.com/forum

This thread is the first hit for the above search term.

For my own notes, I use MyLifeOrganized. It must index every word too, because it narrows search results as fast as you can type. It scales nicely: opens my 16,000+ entry file in less than a second. The "light edition" is free. No Linux/Mac version might be a downside for some.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version