Forum Home
Press F1
 
Thread ID: 59177 2005-06-24 02:52:00 Searching Files based on content... Sardonic (8406) Press F1
Post ID Timestamp Content User
366500 2005-06-24 02:52:00 Dear All

I am wanting to do the following:

I want to search a folder full of text files based on content. Once a specific string is found within a file I want that file deleted immediately. I also would like this search to be done constantly, so that any new files created within the folder that contain the specified string are also immediately deleted.

I can easily find a string using the 'find' or 'findstr' DOS commands, I can even get results saved to separate. Is there a way to get the 'del' command to delete files from the list? Or is there already a freeware program out there that can do all this?

There seems to be a few programs that can do this based on strings within file names but not on content.

There must be something because in MS Exchange SPAM filters can be run that delete unwanted mail based on content. Is there a harddrive equivalent?

Any help would be gratefully received.

Thanks

Sardonic
Sardonic (8406)
366501 2005-06-24 03:18:00 If you are running WinXP just:

1)right-click on the folder containing the text files, click search.

2)put the phrase you want to find in the "Word or Phrase in the file:" Box

3)Click Search.

4)Delete to your heart's content.

PS.. be careful about what you delete

-Qyiet
qyiet (6730)
366502 2005-06-24 03:27:00 If you are running WinXP just:

1)right-click on the folder containing the text files, click search.

2)put the phrase you want to find in the "Word or Phrase in the file:" Box

3)Click Search.

4)Delete to your heart's content.

PS.. be careful about what you delete

-Qyiet

Yeah this works... on NT4 upwards... however I want to automate the process so that I have more time for coffee. The folder concerned is the target for a process that creates 20000+ files a day. All files are then processed further, however certain files do not need processing (and these files can be found by searching for a specific string). Thus by automatically deleting files that need no further action increases the efficency of the whole system.
Sardonic (8406)
366503 2005-06-24 03:33:00 Yeah this works... on NT4 upwards... It does, with slightly different lables on the buttons.

however I want to automate the process so that I have more time for coffee. The folder concerned is the target for a process that creates 20000+ files a day. All files are then processed further, however certain files do not need processing (and these files can be found by searching for a specific string). Thus by automatically deleting files that need no further action increases the efficency of the whole system. I see, I'll have a think.
qyiet (6730)
366504 2005-06-24 03:44:00 What control have you got over the file creation process? If you can make the generating programme use a different extension in the file name for the disposable files, you can then just use a del *.XXX in a scheduled repetitive process.

Searching through 20000 files a day is going to be a significant amount of disk activity. Doing it "continuously" would be a bad idea ...

The DOS batch command processor is not a very capable scripting language. There are ways to do the sort of thing you envisage, but they tend to be messy. One common trick is to have a batch process which writes a batch command file, including (by redirection) a list of filenames to be worked on, then executes this new command file. It's horrible. Perhaps VB might have "proper" ways ... but that would be horrible to me too. I like Turbo Pascal, myself.
Graham L (2)
366505 2005-06-24 04:12:00 Searching through 20000 files a day is going to be a significant amount of disk activity. Doing it "continuously" would be a bad idea ....

Thanks for your response. I have already envisaged the disk activity issue, but thought there might be a way to 'scan' files upon creation thus limiting the activity needed. Using the 'Find' command its very easy to scan for the files. And very easy to delete with a couple of keystrokes/button clicks. But if between searching and deleting any of the files are further processed (and thus removed from the folder) then obviously the file is no longer there to delete which causes errors and stops the whole deletion process.

As the search can take up to 30 minutes (during which files can can processed) I am rarely still at the window when the search completes. Therefore if I return ay an hour later I rarely am able to select all and deete without errors. Thus why I would like the search to happen upon creation.

Its frustrated me for months...
Sardonic (8406)
1