question

ThorElPoderoso-6608 avatar image
0 Votes"
ThorElPoderoso-6608 asked RichMatheisen-8856 answered

compare text files and export result

I need you to help me study to propose a script that compares 2 text files and creates one for me with the same strings. How would you do it? I just need advice.

file1.txt
C:\tmp\1\11111.mp3
C:\tmp\1\11112.mp3
C:\tmp\3\11113.mp3

file2.txt
C:\tmp\1\11111.mp3
C:\tmp\2\11112.mp3
C:\tmp\3\11113.mp3

result.txt
C:\tmp\1\11111.mp3
C:\tmp\3\11113.mp3

windows-serverwindows-server-powershelloffice-js-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

Use Compare-Object:

 (Compare-Object -ReferenceObject (Get-Content c:\junk\file1.txt) -DifferenceObject (Get-Content c:\junk\file2.txt) -IncludeEqual -ExcludeDifferent).InputObject |
     Out-File c:\junk\resultfile.txt
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.