When a batch of TXT files contain useless lines with the same structure, deleting them one by one is very inefficient. This article uses HeSoft Doc Batch Tool to demonstrate how to import multiple txt files, use "Fuzzy Search Text with Formulas" to enter wildcard regular expressions like Annex [A-Z], and leave the replacement content empty, thereby batch deleting all complete lines containing the target keyword. It is suitable for text cleaning, log organization, and data archiving.
In daily office work, TXT text files are often used to store directories, logs, data export results, or system-generated explanatory content. They are lightweight and easy to open, but there is a common problem: when the number of files is very large, any seemingly simple cleanup action becomes repetitive labor. For example, multiple text files contain appendix lines like Annex A, Annex B, and Annex C, and you only want to keep the main table of contents and main text. If you open and delete them file by file, it is not only a waste of time but also prone to missed deletions or mis-deletions due to fatigue.
This article introduces a more suitable batch processing method for office use: using HeSoft Doc Batch Tool , through the "Find and replace complete lines in text files based on keywords" function, combined with wildcard regular expressions to batch delete entire lines containing specified keywords. It is not simply replacing a certain word, but finding and deleting an entire line according to rules, making it especially suitable for processing structured text such as directory lines, comment lines, log lines, and numbered lines.
The following will elaborate on applicable scenarios, effects before and after processing, software operation steps, and precautions, helping you to independently complete batch cleanup of TXT files after reading.
Applicable Scenarios: Batch Deleting Regular Content in Text Files
If your text files contain fixed-format content that needs to be cleaned, you can consider using wildcard regular expressions. The so-called fixed format does not necessarily mean completely identical text; it can also be content that "starts the same but varies later". For example, the Annex A, Annex B, Annex C, and Annex D in this article, although the letters are different, all conform to the pattern of "Annex" plus a space plus an uppercase letter.
This method is suitable for the following scenarios:
- Multiple txt files contain the same type of appendix lines or explanatory lines that need to be deleted in batch;
- Log files contain record lines with a certain identifier that need unified cleanup;
- Data export files have duplicate headers, comments, or page number lines that need to be removed;
- Text materials contain regular lines like "Chapter 1", "Chapter 2" or "Annex A", "Annex B" that need to be processed according to rules;
- You wish to complete batch text cleaning using office software without writing scripts.
HeSoft Doc Batch Tool is a batch document processing tool in office software. Its value lies not in editing a single file, but in applying the same processing action to multiple files. For users who frequently process txt, text materials, and batch export content, this type of function can significantly reduce repetitive labor.
Effect Preview: Files and Content Status Before Batch Processing
Before processing, there were 5 TXT files in the sample folder, namely 1.txt, 2.txt, 3.txt, 4.txt, and 5.txt. This means that this is not a single-file edit, but the execution of a unified rule on a group of text files.

Opening 1.txt, you can see the "Annexes" heading at the top of the file, with contents like Annex A, Annex B, Annex C, and Annex D listed below. These lines also have different descriptive text following them, such as "Food and drink standards - revised 2020" and "The secondary school analysed meal". The Annex A to Annex D lines highlighted by the red box are the target lines to be deleted this time.

If using ordinary find and replace, you might need to process Annex A, Annex B, Annex C, Annex D, and even more letters separately. This would increase the number of rules and is not conducive to future reuse. A more reasonable way is to use a single expression to cover these contents, such as Annex [A-Z], allowing the software to automatically identify similar lines from Annex A to Annex Z.
Effect Preview: Target Entire Lines Deleted After Processing
After completing the batch processing, reviewing the generated text files shows that the original Annex A, Annex B, Annex C, and Annex D lines have disappeared. The top of the file retains "Annexes", followed directly by Contents and specific directory items. The position indicated by the red box shows that the target area has been cleaned.

This processing result indicates that the software did not just delete the characters "Annex A", but deleted the complete line containing the matching content. This is crucial for batch text cleanup. If only the keywords were deleted, the following descriptive text might still remain; deleting the complete line ensures that useless records disappear completely.
Operation Steps: From Importing Files to Setting Regular Expression Deletion Rules
Step 1: Find the Corresponding Function in the Text Tools
After launching HeSoft Doc Batch Tool , you can see multiple tool categories on the left, including Word Tools, Excel Tools, PowerPoint Tools, PDF Tools, Text Tools, etc. Since this processing involves TXT text files, you need to select "Text Tools".
On the Text Tools page, select "Find and replace complete lines in text files based on keywords". From the screenshot prompt, it can be seen that this function is used to batch delete entire lines containing a certain keyword in text files or replace them with new text.

The reason for choosing this function is simple: we want to delete the entire line, not just a specific word. The "complete line" in the function name exactly matches the requirement.
Step 2: Import the txt Files to Be Processed in Batch
After entering the function page, the first step is "Select the records to be processed". The top right area of the interface provides entries such as "Add File" and "Import Files from Folder". For a small number of files, you can add them directly; for a large number of txt files in the same folder, importing from a folder is more suitable.
The example has already imported 5 text files, and the list shows file name, path, extension, creation time, modification time, and other information. Here you can see the file path is located at D:\test\, and the extensions are all txt.

After importing, do not rush to the next step; it is recommended to check three pieces of information first: first, whether the number of files is correct; second, whether the file extensions are all txt to be processed; third, whether the path is the target directory. After confirming there are no errors, click "Next" at the bottom.
Step 3: Set the Search Method to Formula-Based Fuzzy Search
After entering "Set processing options", you need to determine the search method first. In the screenshot, "Use formula-based fuzzy text search" is selected. This option is suitable for using wildcards, range expressions, or similar regex rules to match text.

If you choose ordinary exact search, it usually can only match fixed text; whereas content like Annex A, Annex B, Annex C is similar but not exactly the same. After using formula-based fuzzy search, you can cover multiple variants with one rule.
Step 4: Enter Annex [A-Z] in the Keyword List
Enter the following in the "Keyword list to search for" on the left:
Annex [A-Z]
The purpose of this expression is to match text with "Annex" followed by an uppercase letter. The Annex A, Annex B, Annex C, and Annex D in the example all conform to this rule. Since this function processes complete lines containing the keyword, these lines will be identified as lines to be processed as a whole.
In actual use, you can also adjust the expression according to your own file content. For example, if you want to match numbered lines, you can design an expression corresponding to the numbering pattern; if you want to match lines with a fixed prefix, you can write the fixed prefix into the keyword list. However, this article does not expand on other rules; the focus is on mastering the idea of "using one expression to match a group of similar lines".
Step 5: Leave the Replacement Content Blank to Achieve Deletion of the Entire Line
The area on the right is the "Replacement keyword list". In the screenshot, this area is empty, and the interface has a prompt saying "If left blank, it means delete". Therefore, if your goal is to delete the matching entire line, keep the right side empty and do not enter spaces, symbols, or other text.
This is very important. Leaving it blank means deletion; if you enter other content, the processing result will replace the target line with the specified text instead of removing it. After confirming the left expression and the right blank status, continue by clicking "Next".
Step 6: Set the Save Location and Start Processing
According to the process flow at the top of the page, the subsequent steps are "Set save location" and "Start processing". The save location is used to specify where the processed files will be output. Batch deletion is a non-negligible content change, and it is recommended to save the results to a new location for easy comparison with the original files.
After completing the save location setting, enter the start processing phase, and the software will process files one by one according to the import list. After processing is complete, open the output files to check if the Annex lines have been deleted as expected. If the result is correct, you can apply the same method to more TXT files.
Common Questions and Precautions
1. Is the expression case-sensitive?
In the screenshot, the additional options include "Ignore letter case". If your file might contain Annex A, annex A, or ANNEX A simultaneously, you can check this option as needed. In this article's example, the target content is in standard uppercase form, so this option was not particularly relied upon.
2. Why are blank lines still retained after processing?
From the screenshot after processing, a blank line is retained between Annexes and Contents. This is usually related to the original text structure and the line breaks after deleting lines. The focus of this article is on deleting the entire line containing the matching content; whether to further delete blank lines can be handled later based on actual tidying requirements.
3. Can multiple search rules be entered at once?
The interface shows a "Keyword list to search for", indicating that search items can be managed in a list format. In actual operation, if there are multiple different types of rules, they can be filled in separately. However, it is recommended to start testing with one rule first, confirm the output is correct, and then add more rules to avoid an overly broad match range.
4. Is a backup needed before processing?
It is recommended to keep the original files or output the results to a new folder. The biggest advantage of batch processing is speed, but it also means that an incorrect rule can quickly affect multiple files. First backing up, then testing, and finally executing in batch is a more prudent office workflow.
Summary: Using Rule-Based Batch Processing to Improve Text Cleanup Efficiency
This article demonstrated how to use HeSoft Doc Batch Tool to batch delete entire lines containing specified keywords in TXT files. The core process is: enter Text Tools, select "Find and replace complete lines in text files based on keywords", import multiple txt files, select "Use formula-based fuzzy text search", enter Annex [A-Z], leave the replacement content blank, and finally set the save location and start processing.
Compared to manual editing, this method is more suitable for large numbers of files, repetitive content, and rule-based text cleanup. As long as the target lines have a clear pattern, you can use wildcard regular expressions to hand over repetitive labor to office software. It is recommended that before processing a large batch of files, you first select a few samples to test the rules, and after confirming there are no errors, execute in batch, thus balancing efficiency and safety.