When multiple TXT text files contain fixed-format useless lines, manually deleting them one by one is very inefficient. This article uses the batch deletion of lines containing Annex A, Annex B, Annex C, and Annex D as an example to explain how to use the text tool in HeSoft Doc Batch Tool , import multiple txt files, set precise text search, and leave the replacement content blank to delete entire lines by keyword. This method is suitable for cleaning up directory appendices, log records, exported data, and duplicate descriptions in text content.
Many office scenarios generate a large number of plain text files, such as system-exported txt data, text snippets saved during data organization, log files, documentation, and intermediate files after batch conversion. These files seem simple, but once their numbers increase, cleaning them up becomes very troublesome. Especially when each file contains lines with similar formats but that don't need to be kept, manual deletion is not only time-consuming but also prone to omissions due to fatigue.
This article introduces a more suitable approach for office batch processing: using HeSoft Doc Batch Tool to search for complete lines in text files by keywords and delete these lines in batches. The example uses 5 TXT files, each containing appendix description lines like Annex A, Annex B, Annex C, Annex D. Our goal is not to delete a few characters, but to remove the entire lines containing these keywords from multiple text files in one go.
Applicable Scenarios: Why Batch Delete Entire Lines in TXT by Keyword
Deleting entire lines by keyword is suitable for processing text content where "the whole line is useless, but can be identified by a keyword." For example, many files have the same appendix table of contents at the beginning, with each line starting with content like Annex A, Annex B; log files contain lines with DEBUG, TRACE, or a specific module name; exported data contains records with specific statuses, tags, or numbers; after batch converting documents, fixed headers, footers, or explanatory lines remain in the text.
If only a single keyword is deleted, it may result in incomplete sentences, requiring subsequent manual correction. Deleting entire lines is more suitable for structured cleanup: whenever a target keyword appears in a line, that entire line is removed, preserving the remaining unmatched text. For txt files, plain text materials, and batch-generated text records, this method is cleaner and easier to verify the processing results.
The positioning of HeSoft Doc Batch Tool is that of an office software, with its core value being batch file processing, reducing repetitive labor, and improving efficiency. It is not about asking users to manually edit files one by one, but about centralizing repetitive text cleaning rules and then applying them to multiple files at once.
Pre-processing Effect: Multiple TXT Files Awaiting Unified Cleanup
From the pre-processing screenshot, it can be seen that the folder contains multiple text files like 1.txt, 2.txt, 3.txt, 4.txt, 5.txt. Although the example has only 5 files, in actual work it could very well be dozens or more. If each file had to be opened, searched for Annex, have the corresponding lines deleted, saved, and closed, the overall operation would be highly repetitive.

After opening 1.txt, you can see a text section called Annexes, with four lines listed below: Annex A, Annex B, Annex C, Annex D. These lines contain appendix index descriptions. The goal of this example is to delete these entire lines containing the specified keywords. The subsequent Contents directory and body entries need to be retained and should not be affected.

It's particularly important to note here that the keyword does not necessarily have to equal the entire content of the line. For example, the entire line "Annex A Food and drink standards..." is long, but we only need to use Annex A as the keyword to allow the software to identify the line and execute the deletion. This setup is simpler and more suitable for batch processing similar files.
Post-processing Effect: Target Lines Disappear, Other Content Retained
In the processed file, the previous lines from Annex A to Annex D have been deleted. The screenshot shows that these appendix entries are no longer present under the Annexes title, while the subsequent Contents and numbered directory are still preserved. This indicates that the batch cleanup only acted on the matched lines and did not delete body content that did not contain the keywords.

This effect is suitable for office processing with clear requirements: not altering the overall file structure, not rewriting the entire text, and only deleting lines that meet the condition. For TXT files where most of the content needs to be kept and only a few fixed lines need to be removed, this offers relatively high efficiency and accuracy.
Operation Steps: Batch Delete Entire Lines in Multiple TXT Files by Keyword
Step 1: Find the Corresponding Function in Text Tools
Open HeSoft Doc Batch Tool , and select "Text Tools" on the left side. In the list of Text Tool functions, select "Find and replace complete lines in text files based on keywords". In the screenshot, this function card is indicated, showing it is used for batch processing of complete lines containing keywords in text files.

The purpose of selecting this function is to instruct the software to process text content line by line. Because the requirement of this article is to delete entire lines containing keywords, the standard keyword replacement function should not be chosen. Complete line processing avoids the problem of leaving behind incomplete text after only replacing the keyword.
Step 2: Import the txt Files Needing Batch Cleanup
After entering the function, the top of the page displays the processing flow: select the records to process, set processing options, set save location, and start processing. The first step requires adding files to the list. You can use the "Add File" button at the top right, or batch add via "Import Files from Folder".

In the screenshot, 5 files have been imported, named 1.txt, 2.txt, 3.txt, 4.txt, 5.txt, located in the D:\test\ directory, all with the txt extension. The list also displays the creation and modification times for confirming the correct files are selected. Once confirmed, click "Next" to proceed to keyword setup.
Step 3: Choose Exact Text Search and Enter Keywords
On the "Set Processing Options" page, first configure the search method. In the screenshot, "Exact Text Search" is selected. When the content to be deleted consists of clear, fixed text, such as Annex A, Annex B, Annex C, Annex D, exact search makes it easier to control the matching scope.
Next, enter the keywords in the "List of keywords to find". Each keyword is on a separate line. In the example, 4 lines are entered: Annex A, Annex B, Annex C, Annex D. The "List of replacement keywords" on the right is empty, and the interface indicates that "leaving it blank means deletion". This means that entire lines matching these keywords will be deleted, not replaced with other text.

If you want to delete other content, you can replace the example keywords with your own. For instance, deleting lines containing a specific project code, a status value, or a fixed phrase. The key is to make the keywords specific enough to represent the target lines to be deleted.
Step 4: Set Save Location and Execute Processing
After setting the keywords, click "Next". Following the page flow, the next step is "Set Save Location". It is recommended to save the processed files to a new directory, especially when using this function for the first time. This makes it convenient to compare differences before and after processing and avoids accidentally overwriting the original files.
After confirming the save location, proceed to "Start Processing". The software will sequentially apply the same set of rules to the multiple txt files in the list: searching for lines containing the specified keywords. If a match is found, the entire line is deleted according to the settings. After processing is complete, open one of the result files to check that the target lines have been deleted before using them for official data archiving or subsequent editing.
Common Problems and Precautions
1. Why should the replacement keyword list be left empty?
Because the goal here is to delete entire lines, not to replace them with new text. The prompt "leaving it blank means deletion" is shown in the right area of the screenshot, so keeping it empty is the correct step. If replacement content is filled in, the software might replace the matched lines with the corresponding text instead of deleting them directly.
2. Can multiple keywords be entered at once?
Yes. In the example, four keywords (Annex A, Annex B, Annex C, Annex D) were entered at once. It is generally recommended to have one keyword per line, which makes the list clearer and easier for later review and adjustment.
3. What is the risk of setting keywords too short?
If the keyword is too short or too broad, it might match lines that do not need to be deleted. For example, entering just "Annex" would cause all lines containing "Annex" to be processed; if you only intend to delete Annex A through Annex D, you should enter more specific keywords respectively.
4. Is it necessary to test before batch processing?
It is recommended to test with a small number of files first. Once the processing results meet expectations, import the full folder for batch execution. Especially when dealing with important text, log, or data files, testing and backing up can reduce the risk of accidental deletion.
Summary: Transforming TXT Text Cleanup from Manual Operation to Batch Rules
Batch deleting entire lines in TXT files by keywords is a practical method to improve text cleaning efficiency. With HeSoft Doc Batch Tool , you can import multiple files uniformly, express the lines to be deleted using keyword rules, and let the software automatically perform the search and deletion. Compared to manually operating file by file, this method is faster, more stable, and better suited for repetitive office tasks.
If you also have a large number of txt files needing cleanup, it is recommended to first organize the common keywords of the lines to be deleted, then follow the steps in this article: import files, set up exact search, keep the replacement content empty, and execute processing. This will allow you to complete the batch cleanup of multiple text files in a relatively short time.