Community
    • Login

    How to compare 2 text files and delete duplicates

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    11 Posts 6 Posters 498 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PeterJonesP
      PeterJones @JAK
      last edited by PeterJones

      @JAK ,

      ComparePlus is great for doing a “diff”, where it shows the difference. But it’s not really for quickly/easily deleting extras

      It depends on exactly what you have, but there are some simple ways to delete things from one file that are found in another:

      If you have
      file1:

      apple
      banana
      carrot
      daikon
      eggplant
      fig
      grape
      

      file2:

      apple
      carrot
      jalapeno
      

      If you copy all the contents of file2 and paste them before a --- at the beginning of file1, like:

      apple
      carrot
      jalapeno
      ---
      apple
      banana
      carrot
      daikon
      eggplant
      fig
      grape
      

      Then File > Line Operations > Remove Duplicate Linees will remove the second (or more) occurrence of any line. So the second apple and carrot lines, leaving

      apple
      carrot
      jalapeno
      ---
      banana
      daikon
      eggplant
      fig
      grape
      

      then delete everything before and including the --- line, and your file will now have every line that was in file2 removed from file1. (It will also delete duplicates inside file1, so if file1 had started with an extra fig after the grape, only the first fig would remain.)

      If that doesn’t do what you want, you will have to give more details about your rules.

      Also, if you want an easy way to delete everything before and including the --- line, use FIND WHAT = (?s)\A.*^---\R, REPLACE = empty, Wrap Around = Checkmarked, Search Mode = Regular Expression, Replace All

      JAKJ 1 Reply Last reply Reply Quote 4
      • pnedevP
        pnedev
        last edited by

        Hi @JAK ,

        You can use ComparePlus but from the menu choose Find Unique Lines command. It will mark all unique lines in a file (that are not found in the other file).
        Then use Diff Visual Filters... to hide all diffs (this will hide all unique lines). Don’t worry if there is still one visible diff line on top - first document line cannot be hidden but it is not a problem for the next operation.
        Then select the file from which you’d like to remove duplicating lines (set the focus/caret in that file) and execute Delete all/selected visible lines from the ComparePlus plugin menu.
        This will do what you are trying to accomplish.

        BR

        1 Reply Last reply Reply Quote 5
        • Phil pascalP
          Phil pascal @JAK
          last edited by

          @JAK If you have done any programming, look at Lazarus, it is a very good IDE for Free Pascal, which comes with it. It is free. It has a very easy way to read a text file into a string list (1 line per list entry, used like an array). To do this sort of comparison is basic programming. And great learning a language when there is a real world example to go by.

          1 Reply Last reply Reply Quote -1
          • guy038G guy038 referenced this topic on
          • JAKJ
            JAK @PeterJones
            last edited by JAK

            @PeterJones
            Hello that first option won’t work as I’ll have no idea which duplicates were removed.
            Tried method 2, showered red for all entries that were different and white for duplicate, so used hide matches instead of hide all diffs, this his the white entries, need to do some more examples to be certain.
            When I perform these actions it appears to change the file entries, in the text file does that make sense.

            Just re-read your post, not sure if I’ve made myself clear about what I need.
            I have 2 files, DocMaster with all my music, a second DocNewMusic, which has a list of new music but also contains some tracks already listed in DocMaster, so I want to delete all entries in DocNewMusic that already exist in DocMaster, think we are on the right track, but not certain, the procedure is deleting the correct entries.
            Thanks so much for your perseverance and help. I know some visual basic, but not enough experience to write a plug in, my son writes in Unity, if he had the source code for the Compare plus plugin, maybe he could make a plugin to do what I need in one action.

            Thanks

            CennoxXC 1 Reply Last reply Reply Quote 0
            • CennoxXC
              CennoxX @JAK
              last edited by

              @JAK
              It works like PeterJones said, it’s just the other way around, let’s say DocMaster is

              old
              data
              that
              was
              already
              there
              

              and DocNewMusic is

              old
              and
              new
              data
              that
              was
              not
              already
              there
              

              Then copy the content of DocNewMusic under DocMusic

              old
              data
              that
              was
              already
              there
              ###
              old
              and
              new
              data
              that
              was
              not
              already
              there
              

              File > Line Operations > Remove Duplicate Lines
              and you are left with

              old
              data
              that
              was
              already
              there
              ###
              and
              new
              not
              

              That is DocMaster and beneath that a list of the newly added lines, the correct entries are deleted.

              JAKJ 1 Reply Last reply Reply Quote 1
              • JAKJ
                JAK @CennoxX
                last edited by

                @CennoxX
                Thank you, that’s a very simple way of achieving what I need, will definitely try this. Only downside is that I want to keep thd Master file as is, to use for comparison with future new music lists. Could make a copy for your procedure, then add the new music to it, for the next new music comparison.
                However today I used this procedure, works well, adapted it from the one posted.

                With new music file
                1-use Edit Sort lines lexicographically Ascending, just for clarity
                2-Highlight all lines then use plugins ‘remove Duplicate lines’, as there are always some duplicates
                3-open original Master file and new music file for comparison
                4-Use compare plus and ‘Compare’
                5-Then use Diff Visual Filters… to hide matches
                6-Use find unique lines
                7-copy all selected visible lines from New Music, paste into a new file, to keep them separate, then copy into the Master file, for comparison with the next New music file.

                Hope that makes sense

                This gives me a new file with all new music without any duplicates that exist in the Master file

                1 Reply Last reply Reply Quote 1
                • guy038G
                  guy038
                  last edited by guy038

                  Hello, @jak, @peterjones, @pnedev, @phil-pascal and All,

                  @jak, from this site https://www.americanmusicpreservation.com/100Songsofthe20thCentury.htm I extracted 40 songs, since 1950, that I sorted in randomize order ( Edit > Line Operations > Randomize Line Order ) and listed below :. This will represent our DocMaster.txt file

                  "Maria"                                1957         w: Stephen Sondheim / m: Leonard Bernstein
                  "Camelot"                              1960         w: Alan Jay Lerner / m: Frederick Loewe
                  "Small World"                          1959         w: Stephen Sondheim / m: Jule Styne
                  "I Will Always Love You"               1974 / 1992  w & m: Dolly Parton / arr. Whitney Houston
                  "I Want to Hold Your Hand"             1964         w & m: John Lennon & Paul McCartney
                  "Mack the Knife"                       1955 / 1959  w: Bertold Brecht (trans. by Marc Blitzstein) / m: Kurt Weill
                  "Call Me Irresponsible"                1963         w: Sammy Cahn / m: James Van Heusen
                  "Earth Angel"                          1954         w & m: Curtis Williams
                  "Blowin' in the Wind"                  1962         w & m: Bob Dylan
                  "Bridge Over Troubled Water"           1970         w & m: Paul Simon
                  "Candle in the Wind"                   1973 / 1997  w & m: Bernie Taupin & Elton John / arr.E. John
                  "All the Way"                          1957         w: Sammy Cahn / m: James Van Heusen
                  "Moon River"                           1961         w: Johnny Mercer / m: Henry Mancini
                  "Beauty and the Beast"                 1991         w: Howard Ashman / m: Alan Menken
                  "The Look of Love"                     1967         w: Hal David / m: Burt Bacharach
                  "Your Cheatin' Heart"                  1952         w & m: Hank Williams
                  "Three Coins in the Fountain"          1954         w: Sammy Cahn / m: Jule Styne
                  "Night Fever"                          1978         w & m: Barry, Maurice and Robin Gibb
                  "Goodnight Irene"                      1950         w & m: Huddie (Leadbelly) Ledbetter & Alan Lomax
                  "We Are The World"                     1985         w & m: Michael Jackson & Lionel Richie
                  "The Way We Were"                      1973         w: Alan & Marilyn Bergman / m: Marvin Hamlisch
                  "Sincerely"                            1955         w & m: Harvey Fuqua & Alan Freed
                  "True Love"                            1956         w & m: Cole Porter
                  "On the Street Where You Live"         1956         w: Alan Jay Lerner / m: Frederick Loewe
                  "Rock Around the Clock"                1955         w & m: Max Freedman and Jimmy DeKnight
                  "The First Time Ever I Saw Your Face"  1972         w & m: Ewan MacColl
                  "Just the Way You Are"                 1978         w & m: Billy Joel
                  "Crazy                                 1961         w & m: Willie Nelson
                  "American Pie"                         1971         w & m: Don McLean
                  "Don't Be Cruel"                       1956         w & m: Otis Blackwell
                  "My Way"                               1969         w: Paul Anka / m: Jacques Reveaux and Claude Francois
                  "You Are the Sunshine of My Life"      1973         w & m: Stevie Wonder
                  "You Belong to Me"                     1952         w & m: Pee Wee King, Redd Stewart, Chilton Price
                  "What the World Needs Now is Love"     1965         w: Hal David / m: Burt Bacharach
                  "High Noon"                            1952         w: Ned Washington / m: Dimitri Tiomkin
                  "Yesterday"                            1965         w & m: John Lennon & Paul McCartney
                  "The Shadow of Your Smile"             1965         w: Paul Francis Webster /m: Johnny Mandel
                  "That's What Friends Are For"          1985         w & m: Carole Bayer Sager & Burt Bacharach
                  "Hey Jude"                             1968         w & m: John Lennon & Paul McCartney
                  "My Heart Will Go On"                  1997         w: Will Jennings / m: James Horner
                  

                  On the other hand, from this site https://collider.com/best-songs-21st-century-ranked/ I copied all the songs, that I sorted in randomize order too and listed below. This will represent our DocNewMusic.txt file !

                  "All Too Well"               2021  Taylor Swift
                  "Electric Feel"              2008  MGMT
                  "Hey Ya!"                    2003  Outkast
                  "Bad Guy"                    2019  Billie Eilish
                  "Run Away with Me"           2015  Carly Rae Jepsen
                  "Seven Nation Army"          2003  The White Stripes
                  "Casimir Pulaski Day"        2005  Sufjan Stevens
                  "Bad Romance"                2009  Lady Gaga
                  "Swimming Pools (Drank)"     2012  Kendrick Lamar
                  "Heartbeats"                 2002  The Knife
                  "Good Luck, Babe!"           2024  Chappell Roan
                  "Toxic"                      2004  Britney Spears
                  "Wolf Like Me"               2006  TV on the Radio
                  "Oblivion"                   2012  Grimes
                  "Crazy in Love"              2003  Beyoncé & Jay-Z
                  "Since I Left You"           2000  The Avalanches
                  "Umbrella"                   2007  Rihanna & Jay-Z
                  "Us"                         2004  Regina Spektor
                  "Neighborhood #1 (Tunnels)"  2004  Arcade Fire
                  "Pyramids"                   2012  Frank Ocean
                  "Dancing on My Own"          2010  Robyn
                  "On Melancholy Hill"         2010  Gorillaz
                  "Mr. Brightside"             2003  The Killers
                  "All My Friends"             2007  LCD Soundsystem
                  "Runaway"                    2010  Kanye West & Pusha T
                  

                  As you can verify, DocMaster.txt contains songs before the 21th century ONLY and DocNewMusic.txt contains songs of the 21th century ONLY

                  Now, let’s suppose that we add, on purpose, 10 songs, whose 2 are duplicates, from the DocMaster.txt file, within the DocNewMusic.txt file. We get this updated DocNewMusic.txt file, below :

                  "Rock Around the Clock"                1955         w & m: Max Freedman and Jimmy DeKnight
                  "All Too Well"               2021  Taylor Swift
                  "Electric Feel"              2008  MGMT
                  "Hey Ya!"                    2003  Outkast
                  "Bad Guy"                    2019  Billie Eilish
                  "Run Away with Me"           2015  Carly Rae Jepsen
                  "Candle in the Wind"                   1973 / 1997  w & m: Bernie Taupin & Elton John / arr.E. John
                  "Seven Nation Army"          2003  The White Stripes
                  "Casimir Pulaski Day"        2005  Sufjan Stevens
                  "Bad Romance"                2009  Lady Gaga
                  "Swimming Pools (Drank)"     2012  Kendrick Lamar
                  "I Want to Hold Your Hand"             1964         w & m: John Lennon & Paul McCartney
                  "Heartbeats"                 2002  The Knife
                  "Good Luck, Babe!"           2024  Chappell Roan
                  "Bridge Over Troubled Water"           1970         w & m: Paul Simon
                  "Toxic"                      2004  Britney Spears
                  "All the Way"                          1957         w: Sammy Cahn / m: James Van Heusen
                  "Wolf Like Me"               2006  TV on the Radio
                  "Oblivion"                   2012  Grimes
                  "Crazy in Love"              2003  Beyoncé & Jay-Z
                  "Blowin' in the Wind"                  1962         w & m: Bob Dylan
                  "Since I Left You"           2000  The Avalanches
                  "Umbrella"                   2007  Rihanna & Jay-Z
                  "Night Fever"                          1978         w & m: Barry, Maurice and Robin Gibb
                  "Us"                         2004  Regina Spektor
                  "Neighborhood #1 (Tunnels)"  2004  Arcade Fire
                  "Pyramids"                   2012  Frank Ocean
                  "Dancing on My Own"          2010  Robyn
                  "Yesterday"                            1965         w & m: John Lennon & Paul McCartney
                  "On Melancholy Hill"         2010  Gorillaz
                  "Mr. Brightside"             2003  The Killers
                  "All My Friends"             2007  LCD Soundsystem
                  "Blowin' in the Wind"                  1962         w & m: Bob Dylan
                  "Bridge Over Troubled Water"           1970         w & m: Paul Simon
                  "Runaway"                    2010  Kanye West & Pusha T
                  

                  If I understand you correctly, You would like to delete all lines of the present DocNewMusic.txt which ALSO belong to DocMaster.txt


                  I’m going to describe two methods to achieve your goal. For the second one, see my next post !

                  (1) By running a search/ replacement with regular expressions :

                  • At the end of the DocNewMusic.txt file, add a simple line with, at least, 3 equal signs

                  • Append all the contents of the DocMaster.txt file, right after that line of equal signs

                  So, the DocNewMusic.txt is temporarily changed as below :

                  "Rock Around the Clock"                1955         w & m: Max Freedman and Jimmy DeKnight
                  "All Too Well"               2021  Taylor Swift
                  "Electric Feel"              2008  MGMT
                  "Hey Ya!"                    2003  Outkast
                  "Bad Guy"                    2019  Billie Eilish
                  "Run Away with Me"           2015  Carly Rae Jepsen
                  "Candle in the Wind"                   1973 / 1997  w & m: Bernie Taupin & Elton John / arr.E. John
                  "Seven Nation Army"          2003  The White Stripes
                  "Casimir Pulaski Day"        2005  Sufjan Stevens
                  "Bad Romance"                2009  Lady Gaga
                  "Swimming Pools (Drank)"     2012  Kendrick Lamar
                  "I Want to Hold Your Hand"             1964         w & m: John Lennon & Paul McCartney
                  "Heartbeats"                 2002  The Knife
                  "Good Luck, Babe!"           2024  Chappell Roan
                  "Bridge Over Troubled Water"           1970         w & m: Paul Simon
                  "Toxic"                      2004  Britney Spears
                  "All the Way"                          1957         w: Sammy Cahn / m: James Van Heusen
                  "Wolf Like Me"               2006  TV on the Radio
                  "Oblivion"                   2012  Grimes
                  "Crazy in Love"              2003  Beyoncé & Jay-Z
                  "Blowin' in the Wind"                  1962         w & m: Bob Dylan
                  "Since I Left You"           2000  The Avalanches
                  "Umbrella"                   2007  Rihanna & Jay-Z
                  "Night Fever"                          1978         w & m: Barry, Maurice and Robin Gibb
                  "Us"                         2004  Regina Spektor
                  "Neighborhood #1 (Tunnels)"  2004  Arcade Fire
                  "Pyramids"                   2012  Frank Ocean
                  "Dancing on My Own"          2010  Robyn
                  "Yesterday"                            1965         w & m: John Lennon & Paul McCartney
                  "On Melancholy Hill"         2010  Gorillaz
                  "Mr. Brightside"             2003  The Killers
                  "All My Friends"             2007  LCD Soundsystem
                  "Blowin' in the Wind"                  1962         w & m: Bob Dylan
                  "Bridge Over Troubled Water"           1970         w & m: Paul Simon
                  "Runaway"                    2010  Kanye West & Pusha T
                  ===============
                  "Maria"                                1957         w: Stephen Sondheim / m: Leonard Bernstein
                  "Camelot"                              1960         w: Alan Jay Lerner / m: Frederick Loewe
                  "Small World"                          1959         w: Stephen Sondheim / m: Jule Styne
                  "I Will Always Love You"               1974 / 1992  w & m: Dolly Parton / arr. Whitney Houston
                  "I Want to Hold Your Hand"             1964         w & m: John Lennon & Paul McCartney
                  "Mack the Knife"                       1955 / 1959  w: Bertold Brecht (trans. by Marc Blitzstein) / m: Kurt Weill
                  "Call Me Irresponsible"                1963         w: Sammy Cahn / m: James Van Heusen
                  "Earth Angel"                          1954         w & m: Curtis Williams
                  "Blowin' in the Wind"                  1962         w & m: Bob Dylan
                  "Bridge Over Troubled Water"           1970         w & m: Paul Simon
                  "Candle in the Wind"                   1973 / 1997  w & m: Bernie Taupin & Elton John / arr.E. John
                  "All the Way"                          1957         w: Sammy Cahn / m: James Van Heusen
                  "Moon River"                           1961         w: Johnny Mercer / m: Henry Mancini
                  "Beauty and the Beast"                 1991         w: Howard Ashman / m: Alan Menken
                  "The Look of Love"                     1967         w: Hal David / m: Burt Bacharach
                  "Your Cheatin' Heart"                  1952         w & m: Hank Williams
                  "Three Coins in the Fountain"          1954         w: Sammy Cahn / m: Jule Styne
                  "Night Fever"                          1978         w & m: Barry, Maurice and Robin Gibb
                  "Goodnight Irene"                      1950         w & m: Huddie (Leadbelly) Ledbetter & Alan Lomax
                  "We Are The World"                     1985         w & m: Michael Jackson & Lionel Richie
                  "The Way We Were"                      1973         w: Alan & Marilyn Bergman / m: Marvin Hamlisch
                  "Sincerely"                            1955         w & m: Harvey Fuqua & Alan Freed
                  "True Love"                            1956         w & m: Cole Porter
                  "On the Street Where You Live"         1956         w: Alan Jay Lerner / m: Frederick Loewe
                  "Rock Around the Clock"                1955         w & m: Max Freedman and Jimmy DeKnight
                  "The First Time Ever I Saw Your Face"  1972         w & m: Ewan MacColl
                  "Just the Way You Are"                 1978         w & m: Billy Joel
                  "Crazy                                 1961         w & m: Willie Nelson
                  "American Pie"                         1971         w & m: Don McLean
                  "Don't Be Cruel"                       1956         w & m: Otis Blackwell
                  "My Way"                               1969         w: Paul Anka / m: Jacques Reveaux and Claude Francois
                  "You Are the Sunshine of My Life"      1973         w & m: Stevie Wonder
                  "You Belong to Me"                     1952         w & m: Pee Wee King, Redd Stewart, Chilton Price
                  "What the World Needs Now is Love"     1965         w: Hal David / m: Burt Bacharach
                  "High Noon"                            1952         w: Ned Washington / m: Dimitri Tiomkin
                  "Yesterday"                            1965         w & m: John Lennon & Paul McCartney
                  "The Shadow of Your Smile"             1965         w: Paul Francis Webster /m: Johnny Mandel
                  "That's What Friends Are For"          1985         w & m: Carole Bayer Sager & Burt Bacharach
                  "Hey Jude"                             1968         w & m: John Lennon & Paul McCartney
                  "My Heart Will Go On"                  1997         w: Will Jennings / m: James Horner
                  
                  • Select the DocNewMusic.txt file

                  • Open the Replace dialog ( Ctrl + H )

                  • Uncheck all box options

                  • SEARCH (?x-is) ^ (.+\R) (?= (?s) .+? ^===+ .+ ^ \1) | (?s) ^ ===.+

                  • REPLACE Leave EMPTY

                  • Tick the Wrap around option

                  • Select the Regular expression search mode ( IMPORTANT )

                  • Click on the Replace All button

                  You should get the new DocNewMusic.txt file, below :

                  "All Too Well"               2021  Taylor Swift
                  "Electric Feel"              2008  MGMT
                  "Hey Ya!"                    2003  Outkast
                  "Bad Guy"                    2019  Billie Eilish
                  "Run Away with Me"           2015  Carly Rae Jepsen
                  "Seven Nation Army"          2003  The White Stripes
                  "Casimir Pulaski Day"        2005  Sufjan Stevens
                  "Bad Romance"                2009  Lady Gaga
                  "Swimming Pools (Drank)"     2012  Kendrick Lamar
                  "Heartbeats"                 2002  The Knife
                  "Good Luck, Babe!"           2024  Chappell Roan
                  "Toxic"                      2004  Britney Spears
                  "Wolf Like Me"               2006  TV on the Radio
                  "Oblivion"                   2012  Grimes
                  "Crazy in Love"              2003  Beyoncé & Jay-Z
                  "Since I Left You"           2000  The Avalanches
                  "Umbrella"                   2007  Rihanna & Jay-Z
                  "Us"                         2004  Regina Spektor
                  "Neighborhood #1 (Tunnels)"  2004  Arcade Fire
                  "Pyramids"                   2012  Frank Ocean
                  "Dancing on My Own"          2010  Robyn
                  "On Melancholy Hill"         2010  Gorillaz
                  "Mr. Brightside"             2003  The Killers
                  "All My Friends"             2007  LCD Soundsystem
                  "Runaway"                    2010  Kanye West & Pusha T
                  
                  • Save these modifications which represents your expected DocNewMusic.txt file.

                  Here you are ! You can verify that it remains ONLY songs of the 21th century and that all the songs from the 20th century, belonging to the DocMaster.txt file, are gone from the DocNewMusic.txt file !

                  Continuation on next post

                  guy038

                  1 Reply Last reply Reply Quote 0
                  • guy038G
                    guy038
                    last edited by guy038

                    Hi, @jak and All,

                    (2) By using the ComparePlus plugin

                    So, we start with the file DocMaster.txt, below :

                    "Maria"                                1957         w: Stephen Sondheim / m: Leonard Bernstein
                    "Camelot"                              1960         w: Alan Jay Lerner / m: Frederick Loewe
                    "Small World"                          1959         w: Stephen Sondheim / m: Jule Styne
                    "I Will Always Love You"               1974 / 1992  w & m: Dolly Parton / arr. Whitney Houston
                    "I Want to Hold Your Hand"             1964         w & m: John Lennon & Paul McCartney
                    "Mack the Knife"                       1955 / 1959  w: Bertold Brecht (trans. by Marc Blitzstein) / m: Kurt Weill
                    "Call Me Irresponsible"                1963         w: Sammy Cahn / m: James Van Heusen
                    "Earth Angel"                          1954         w & m: Curtis Williams
                    "Blowin' in the Wind"                  1962         w & m: Bob Dylan
                    "Bridge Over Troubled Water"           1970         w & m: Paul Simon
                    "Candle in the Wind"                   1973 / 1997  w & m: Bernie Taupin & Elton John / arr.E. John
                    "All the Way"                          1957         w: Sammy Cahn / m: James Van Heusen
                    "Moon River"                           1961         w: Johnny Mercer / m: Henry Mancini
                    "Beauty and the Beast"                 1991         w: Howard Ashman / m: Alan Menken
                    "The Look of Love"                     1967         w: Hal David / m: Burt Bacharach
                    "Your Cheatin' Heart"                  1952         w & m: Hank Williams
                    "Three Coins in the Fountain"          1954         w: Sammy Cahn / m: Jule Styne
                    "Night Fever"                          1978         w & m: Barry, Maurice and Robin Gibb
                    "Goodnight Irene"                      1950         w & m: Huddie (Leadbelly) Ledbetter & Alan Lomax
                    "We Are The World"                     1985         w & m: Michael Jackson & Lionel Richie
                    "The Way We Were"                      1973         w: Alan & Marilyn Bergman / m: Marvin Hamlisch
                    "Sincerely"                            1955         w & m: Harvey Fuqua & Alan Freed
                    "True Love"                            1956         w & m: Cole Porter
                    "On the Street Where You Live"         1956         w: Alan Jay Lerner / m: Frederick Loewe
                    "Rock Around the Clock"                1955         w & m: Max Freedman and Jimmy DeKnight
                    "The First Time Ever I Saw Your Face"  1972         w & m: Ewan MacColl
                    "Just the Way You Are"                 1978         w & m: Billy Joel
                    "Crazy                                 1961         w & m: Willie Nelson
                    "American Pie"                         1971         w & m: Don McLean
                    "Don't Be Cruel"                       1956         w & m: Otis Blackwell
                    "My Way"                               1969         w: Paul Anka / m: Jacques Reveaux and Claude Francois
                    "You Are the Sunshine of My Life"      1973         w & m: Stevie Wonder
                    "You Belong to Me"                     1952         w & m: Pee Wee King, Redd Stewart, Chilton Price
                    "What the World Needs Now is Love"     1965         w: Hal David / m: Burt Bacharach
                    "High Noon"                            1952         w: Ned Washington / m: Dimitri Tiomkin
                    "Yesterday"                            1965         w & m: John Lennon & Paul McCartney
                    "The Shadow of Your Smile"             1965         w: Paul Francis Webster /m: Johnny Mandel
                    "That's What Friends Are For"          1985         w & m: Carole Bayer Sager & Burt Bacharach
                    "Hey Jude"                             1968         w & m: John Lennon & Paul McCartney
                    "My Heart Will Go On"                  1997         w: Will Jennings / m: James Horner
                    

                    And the file DocNewMusic, below :

                    "Rock Around the Clock"                1955         w & m: Max Freedman and Jimmy DeKnight
                    "All Too Well"               2021  Taylor Swift
                    "Electric Feel"              2008  MGMT
                    "Hey Ya!"                    2003  Outkast
                    "Bad Guy"                    2019  Billie Eilish
                    "Run Away with Me"           2015  Carly Rae Jepsen
                    "Candle in the Wind"                   1973 / 1997  w & m: Bernie Taupin & Elton John / arr.E. John
                    "Seven Nation Army"          2003  The White Stripes
                    "Casimir Pulaski Day"        2005  Sufjan Stevens
                    "Bad Romance"                2009  Lady Gaga
                    "Swimming Pools (Drank)"     2012  Kendrick Lamar
                    "I Want to Hold Your Hand"             1964         w & m: John Lennon & Paul McCartney
                    "Heartbeats"                 2002  The Knife
                    "Good Luck, Babe!"           2024  Chappell Roan
                    "Bridge Over Troubled Water"           1970         w & m: Paul Simon
                    "Toxic"                      2004  Britney Spears
                    "All the Way"                          1957         w: Sammy Cahn / m: James Van Heusen
                    "Wolf Like Me"               2006  TV on the Radio
                    "Oblivion"                   2012  Grimes
                    "Crazy in Love"              2003  Beyoncé & Jay-Z
                    "Blowin' in the Wind"                  1962         w & m: Bob Dylan
                    "Since I Left You"           2000  The Avalanches
                    "Umbrella"                   2007  Rihanna & Jay-Z
                    "Night Fever"                          1978         w & m: Barry, Maurice and Robin Gibb
                    "Us"                         2004  Regina Spektor
                    "Neighborhood #1 (Tunnels)"  2004  Arcade Fire
                    "Pyramids"                   2012  Frank Ocean
                    "Dancing on My Own"          2010  Robyn
                    "Yesterday"                            1965         w & m: John Lennon & Paul McCartney
                    "On Melancholy Hill"         2010  Gorillaz
                    "Mr. Brightside"             2003  The Killers
                    "All My Friends"             2007  LCD Soundsystem
                    "Blowin' in the Wind"                  1962         w & m: Bob Dylan
                    "Bridge Over Troubled Water"           1970         w & m: Paul Simon
                    "Runaway"                    2010  Kanye West & Pusha T
                    

                    • First, use the Plugins > ComparePlus > Diff Visual Filters... option

                    • Check the Hide added/removed lines option and valid this choice with the OK button

                    • Then, use the specific option Plugins > ComparePlus > Find Unique lines

                    • Now, select the DocNewMusic.txt file ( IMPORTANT )

                    • Run the Plugin > ComparePlus > Delete all/selected visible lines option

                    • Run the Plugin > ComparePlus > Clear Active Compare option

                    • Finally, save the modifications of the DocNewMusic.txt file ( IMPORTANT )

                    Again, you should see that, after process, the saved version of the DocNewMusic.txt file does not contain any song of the 20th century !

                    Best Regards,

                    guy038

                    JAKJ 1 Reply Last reply Reply Quote 2
                    • JAKJ
                      JAK @guy038
                      last edited by

                      @guy038
                      Hello
                      I really appreciate all your hard work.

                      I’ve been trying myself to achieve what I need.
                      In your 2nd example, you say that the ‘modified’ new music file doesn’t have any 20th century tracks, but to get what I need, it Must have Only the 20th century tracks, as these do not appear in the master file.

                      Hope this will explain clearer what I need.

                      ​Hi

                      Just realised that I’ve not made myself clear.

                      I have 2 text files

                      1-original music collection

                      2-new music

                      What I actually need is a modified file or list of the new music file, with any tracks that exist in the original file removed.

                      So if the original file has

                      -Coldplay yellow

                      -Elton John Rocket man

                      -Beatles abbey road

                      -Beatles Love me do

                      -Beatles hey Jude

                      -Monkees daydream believer

                      And the new music file has

                      -Beatles abbey road

                      -Beatles Love me do

                      -Beatles hey Jude

                      -Monkees daydream believer

                      -The move blackberry way

                      Then the ‘modified’ new music file would only have

                      -The move blackberry way

                      'So that the ‘modified’ new music file Only has any entries that are Not in the ‘original’ file
                      👍

                      1 Reply Last reply Reply Quote 0
                      • guy038G
                        guy038
                        last edited by guy038

                        Hi, @jak, @peterjones, @pnedev, @phil-pascal and All,

                        Ah…, OK :! But it’s quite funny, @jak, because it’s exactly what I proposed in my last two posts !!!

                        Giving the initial contents of your two files :

                        • The Original Music Collection which contains :
                        Coldplay yellow
                        Elton John Rocket man
                        Beatles abbey road
                        Beatles Love me do
                        Beatles hey Jude
                        Monkees daydream believer
                        
                        • The New Music file which contains :
                        Beatles abbey road
                        Beatles Love me do
                        Beatles hey Jude
                        Monkees daydream believer
                        The move blackberry way
                        

                        (1) By running a search/ replacement with regular expressions :

                        I append, at the very end of the New music file, the contents of the Original Music Collection file, after a line of, at least, 3 equal signs, giving this temporary New music file :

                        Beatles abbey road
                        Beatles Love me do
                        Beatles hey Jude
                        Monkees daydream believer
                        The move blackberry way
                        ==========
                        Coldplay yellow
                        Elton John Rocket man
                        Beatles abbey road
                        Beatles Love me do
                        Beatles hey Jude
                        Monkees daydream believer
                        

                        Now :

                        • Switch to the New Music file

                        • Open the Replace dialog ( Ctrl + H )

                        • Uncheck all box options

                        • SEARCH (?x-is) ^ (.+\R) (?= (?s) .+? ^===+ .+ ^ \1) | (?s) ^ ===.+

                        • REPLACE Leave EMPTY

                        • Tick the Wrap around option

                        • Select the Regular expression search mode ( IMPORTANT )

                        • Click on the Replace All button

                        => You should get your expected New Music file, below :

                        The move blackberry way
                        
                        • Save the modification of the New Music file

                        (2) By using the ComparePlus plugin :

                        • First, use the Plugins > ComparePlus > Diff Visual Filters... option

                        • Check the Hide added/removed lines option and valid this choice with the OK button

                        • Then, use the specific option Plugins > ComparePlus > Find Unique lines

                        • Now, select the New Music file ( IMPORTANT )

                        • Run the Plugins > ComparePlus > Delete all/selected visible lines option

                        • Run the Plugins > ComparePlus > Clear Active Compare option

                        • Finally, save the modifications of the New Music file ( IMPORTANT )

                        Best Regards,

                        guy038

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors