Jump to content

Recommended Posts

Posted

Hello

What is the best way to search for a string/line in a text file and then delete the file if it contains the line/string you are looking for?

My chalange is to search all the text files stored in a directory, and i want to delete all the files that contains a string more than 5 times.

ex:

this is a test

this is a test

this is a test

tjis is a test

Anyone with a good idea :whistle: ?

Posted

FileFindFirstFile & FileFindNextFile to locate the text files.

FileRead to get contents of each text file as the loop goes round.

StringReplace to find how many instances of the string exists in the text file.

Use FileDelete to delete chosen text files that match your condition.

That should help get you started.

:whistle:

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...