1

I want to find out if there are any extra files between a long list of files that I generated. Because I`m weak at explaining stuff with words, I'd rather illustrate.

This is an illustration of the list of files that I have inside a Notepad++ session at the moment: (numerals represent line count)

1   gold.txt
2   silver.txt
3   copper.txt
4
5
6   gold.txt
7   silver.txt
8   copper.txt
9   unknown.txt

And the following is what I'm trying to achieve:

1
2
3
4
5
6
7
8
9   unknown.txt

How to remove everything with an exception of unknown.txt?

2
3

Select menu Edit > Line Operations > Sort Lines Lexicographically Ascending to sort your file. Then press Ctrl+H to replace the texts like below

  • Find what: ^(.*?\R)(\1)+
  • Replace with: empty
  • Search mode: regular expression, with the option . matches newline unchecked

Then press replace all

Notepad++ sort lines

This will not leave the unknown.txt at the 9th line as your example, but it works

A better solution would be using the TextFX plugin. Just select TextFX > Click TextFX Tools > Check +Sort outputs only UNIQUE (at column) lines then remove the duplicates by selecting TextFX > TextFX Tools > Sort lines case insensitive (at column)

TextFX sort lines

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.