0

I want to make a batch file that can find a specific text file not by name but by its contents better yet not by its entire contents but rather by selected parts of it.

For instance if I have a txt file with the contents

Tom-Dick-and-Harry

I would like my batch file to calculate that if there is a line anywhere in the txt file that contains a T and if 7 characters on from that the letter is a K and two characters on from that the letter is an A the file is recognised as being my file and it is deleted.

Perhaps better explained by a batch file that can find a “fingerprint” this way others can rename my txt file but I will still find it…

How could I achieve this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
LabRat
  • 1,996
  • 11
  • 56
  • 91
  • On windows I assume? Try to find some regular expression library, that might do the trick. Python/Perl/… would come in handy here. – Jonas Schäfer Oct 18 '12 at 11:35
  • I assume batch usualy means windows? and preferably without python its to much of a learning curve for me... – LabRat Oct 18 '12 at 11:42
  • It sounds like you want to use *fuzzy hashing*. Check out [`ssdeep`](http://ssdeep.sourceforge.net/), it's pretty good with this sort of thing. – newfurniturey Oct 18 '12 at 19:50

1 Answers1

0

You can use findstr

for /f "delims=*" %%f in ('"findstr /r /m /c:T.......K..A *.FILEEXT"') do (
    del "%%f"
)
Alex K.
  • 171,639
  • 30
  • 264
  • 288