Erlend Posted July 14, 2007 Share Posted July 14, 2007 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 ? Link to comment Share on other sites More sharing options...
MHz Posted July 14, 2007 Share Posted July 14, 2007 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now