| View previous topic :: View next topic |
| Author |
Message |
twhyman
Joined: 07 Dec 2005 Posts: 264
|
Posted: Sun May 07, 2006 12:15 pm Post subject: How to compare two lists? |
|
|
Hi,
i have two txt files containing file name.
i want to compare them and recive a file containing the differnce.
| Code: |
Example:
File1.txt Vs. File2.txt = File3.txt
--------- --------- ----------
a.jpg a.jpg The Differnce is:
b.jpg b.jpg d.jpg
c.jpg c.jpg
d.jpg
|
there is a script that compars two TXT files but its result is that line 3 wich c.jpg is the differnce, here is the SCRIPT
what i really need is compare content not lines.
how can i fix it?
Thanks
TwhyMan |
|
| Back to top |
|
 |
foom
Joined: 19 Apr 2006 Posts: 386
|
Posted: Sun May 07, 2006 2:48 pm Post subject: |
|
|
Does this work for you?
| Code: | FileRead, ContentsA, file1.txt
FileRead, ContentsB, file2.txt
Loop, Parse, ContentsA , `n, `r
{
IfNotInString, ContentsB, %A_LoopField%
result:=result . A_LoopField . "`n"
}
Loop, Parse, ContentsB , `n, `r
{
IfNotInString, ContentsA, %A_LoopField%
result:=result . A_LoopField . "`n"
}
msgbox, % result |
|
|
| Back to top |
|
 |
twhyman
Joined: 07 Dec 2005 Posts: 264
|
Posted: Sun May 07, 2006 6:18 pm Post subject: |
|
|
Yes it does foom,
thanks alot  |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Tue May 09, 2006 9:25 am Post subject: |
|
|
foom, this is smart, but with a drawback: if there is SomeFile.jpg in A and File.jpg in B, the second file will be "found" in A.
Of course, if all file names have the same length, or if you are sure this case never happens, you can safely use this script. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
emirvisir
Joined: 07 Dec 2006 Posts: 42
|
Posted: Fri Apr 20, 2007 5:47 pm Post subject: |
|
|
does this work the same when the lists are contained in variables?
I want to compare two Winget ControlListHwnd commands, to be able to send events directly to a new control which appears at a given point. |
|
| Back to top |
|
 |
Andi
Joined: 11 Feb 2005 Posts: 157 Location: Germany, Niestetal
|
Posted: Sat Apr 21, 2007 6:51 am Post subject: |
|
|
The script compares already two variables ContentsA with
ContentsB  |
|
| Back to top |
|
 |
emirvisir
Joined: 07 Dec 2006 Posts: 42
|
Posted: Sat Apr 21, 2007 11:27 am Post subject: |
|
|
heh, I guess I did not read the code too attentively... thanks for pointing that out  |
|
| Back to top |
|
 |
|