• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1430
  • Last Modified:

Delete specific rows in a text file

Hi,

I need some help to delete rows in a text file which contain specific text.  The text file is a log of a backup session.  Would there be any quick way to exclude/delete all the lines which contain the text "$backup.dir".  As there are probably over 100 occurrences of this text, manual deletion is not the way to go.

I'm an absolute newbie at vb or macros.  If there is a solution for dummies, it would be wonderful.  

Many thanks to all who can help.

Regards

Chiarne
0
Chiarne
Asked:
Chiarne
  • 3
  • 2
1 Solution
 
NicksonKohCommented:
Hi Chiarne,

This I think is easiest done in Excel with either sort or filtering. Follow the below steps

1) Open the text file in Excel.
2) Provide a simple header to do an auto filtering.
3) From the filter dropdown select that specific text or u can use the custom to specify the column is to contain certain text.
4) Select all these filtered rows and delete.
5) Use Save As to save the file back as a text file.

Cheers,
NicksonKoh
0
 
gregwestmorelandCommented:
You do not need to import your text into an Excel file or any other software. Hold the Ctrl + H button down. Type in "Find What Text" with Replace With Text" (leave blank) and then select Replace All. Problem solved!!!
0
 
ChiarneAuthor Commented:
Hi gregwestmoreland,

I have tried what you suggested but only the text "$backup.dir" is deleted, not the whole line of text with the words "$backup.dir".

Regards

Chiarne
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
ChiarneAuthor Commented:
Hi NicksonKoh,

When you suggest to create a header, do you mean just add another row at the top of the spreadsheet and enter the text "$backup.dir".

Here's an example of the type of lines I would like to delete:

Deleting: E:\Bak_C\Users Shared Folders\wayne\~old wayne data\My Documents\unit437-39evan\$backup.dir
Deleting: E:\Bak_C\Users Shared Folders\wayne\~old wayne data\My Documents\unit1237-39evan\$backup.dir
Deleting: E:\Bak_C\Users Shared Folders\wayne\~old wayne data\My Documents\TEMPLATES\$backup.dir

Regards

Chiarne
0
 
NicksonKohCommented:
No exactly, just insert a blank row at the top and give it some header name like e.g. "Folder". The header row is just a dummy row to separate the data from the filter row. It's optional and is only a neater way to do things.

After you insert the header row, you do the filter from Tools > Filter. A dropdown will appear beside on the header. From the dropdown, choose custom and in that filter dialog, choose contains and enter "$backup.dir"

0
 
ChiarneAuthor Commented:
Hi NicksonKoh,

Brilliant. That little bit of extra information did the trick.  Problem solved.

Thanks heaps.

Chiarne
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now