I have several hundreds of .txt files from which I would like to remove the lines where only the word "Volume" followed by a number appears. The word "Volume" may appear several times in each text file but I only want to delete the lines where the only text on that line is Volume and some number.

Example of line I want to be deleted:

                 Volume 158

Example of line I don't want to be deleted:

  text text text Volume 158 text text text

Please help me accomplish this using notepad++ ?


Using the regular expression:

^\s*Volume \d+\s*$

you should be able to do it fairly easily by replacing with blank, e.g.



What you are trying to do is involves complex logic that is not going to be possible, even in an advanced text editor like Notepad++. In addition, your problem is not precisely defined (for example, is "12.3" a number or not?). Only you know your exact requirements.

Depending on how technical you are, you could adapt the following C# code to do exactly what you want. You'll need Visual Studio Express or similar. You can of course write this in another language or try and find an alternate solution. Note that the code will delete lines starting with "Volume ", even if the following text is not a number. You'll need to deal with exactly what processing you want. Also, the code deals with files specifically by name. If you want to recurse all files in a folder, say, that's another detail you may need to consider:

// Read the file line by line
string szOriginal = @"C:\Tmp\Test.txt";
string szCopy = @"C:\Tmp\Test.txt.tmp";
StreamReader fText = new StreamReader(szOriginal);
StreamWriter fCopy = new StreamWriter(szCopy);

string szLine = string.Empty;
int nIndex = 0;
while ((szLine = fText.ReadLine()) != null)
    // Don't copy lines starting with "Volume " (note space character)
    nIndex = szLine.IndexOf("Volume ");
    if (nIndex != 0)


// Delete original and rename copy
File.Move(szCopy, szOriginal);

Create an empty Windows Forms project, add a button, double-click the button (to view the code in the editor), paste in the above code (with any modifications, if required), run the code and click the button. Good luck!


delete lines that contains exactly Volume 158

FIND: ^.*(Volume 158).*$


or delete lines which contains one of the two words Volume or 158

FIND: ^.*(Volume).*$|^.*(158).*$


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.