Jump to content
Sign in to follow this  

searching for a string in two files

Recommended Posts


I got two .txt files (like the one attached).

I make these files daily. So every file will be different. (500-2000 lines).

What i need is a function to start at top of file1.txt and see if it finds this line in file2.txt. And so on with all lines in file1.txt (not sorted). And if it finds a line that is in both file1.txt and file2.txt it shuld write it to a new file.

I could solve this by making a while inside a while sentence, but that wouldent be so effective.

This brings me to my question:

Can this be done effective (and relativly easy)

Any suggestions are welcome. =)



Share this post

Link to post
Share on other sites

fileread both files.

you can do it a couple ways after that.

assume @crlf for breaks.

just off the top of my head, might have a bug in it.


for $i=1 to $fileline1[0]
if stringinstr(@crlf & $file2 & @crlf,@crlf & $fileline1[$i] & @crlf) _
and $fileline1[$i]<>"" then filewrite("found.txt",$fileline1[$i] & @crlf)

func Filereadall($_file)
return $_file

edit added code for blank lines..

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post

Link to post
Share on other sites

Thanks scriptkitty. works perfect. Now i just have to understand it :).

Share this post

Link to post
Share on other sites

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

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.