How to batch replace similar content in multiple text files: A tutorial on wildcard search and replace


Translation:EnglishFrançaisDeutschEspañol日本語한국어,Update Time:2026-07-03 07:00:42

Disclaimer: All images, text, and video content on the website are for reference only and may not be the latest, correct, or accurate. In case of any dispute, please refer to the actual experience effect!

When dealing with a batch of TXT files, if each file contains different numbers or codes that need to be replaced, manual find and replace can be very inefficient. This article starts from real office scenarios and explains how to use HeSoft Doc Batch Tool to import multiple text files into the same task, and input the \d+ rule through "use formula to fuzzy find text" to uniformly replace all matched numbers with AAA. The article includes comparison of before and after effects, detailed operation steps, and precautions, helping users master the method of batch find and replace for text content.

In daily office work, text files are not just used for simple notes. Logs exported by various systems, database documentation, training materials, web-scraped content, data annotations, and technical documents often end up being saved in TXT format. When there are many such files and they contain similar content that needs to be uniformly replaced, the traditional manual approach becomes very inefficient.

For example, consider a batch of TXT files on astronomy topics that contain numerous numbers: masses, distances, radii, years, quantities, etc. If you need to uniformly replace all these numbers with a placeholder like AAA for data masking, testing, or templating, opening files like big_bang.txt, black_holes.txt, dark_energy.txt individually is clearly not an ideal solution. A better approach is to use the batch processing function in office software, completing the replacement in one go using wildcards or regular expressions.

This article will introduce how to use HeSoft Doc Batch Tool to batch find and replace keywords in multiple text files. This software is a file batch processing tool within office software, and its core value lies in batch processing files, reducing repetitive labor, and improving processing efficiency. The following uses "replacing all numbers in multiple TXT files with AAA" as an example to fully explain the processing logic and operational steps.

Applicable Scenarios: Most Suitable When Specific Keywords Are Unknown, but Content Patterns Are Recognized

Standard find and replace requires you to know the specific text to find, such as finding "2026" and replacing it with "2027". However, often what we want to replace is not a single fixed term, but a category of content. Examples include all numbers, all serial numbers, all version numbers, or all date segments. This requires wildcard or regular expression searches.

This tutorial applies to the following scenarios:

  • Batch replacing numbers in multiple txt files: For example, uniformly replacing numerical values in documents with AAA, ***, or other placeholder content.
  • Batch masking text content: Replacing sensitive information like phone numbers, IDs, amounts, and statistical values by rules.
  • Batch standardizing data templates: Replacing variable fields across different files with unified markers for easier future reuse.
  • Batch processing logs or exported files: Performing unified cleanup on large amounts of text generated by systems.
  • Batch replacing variable content in English texts: For instance, numbers, unit values, and serial numbers interspersed within English materials.

If you only have one file, manual processing might be acceptable; but when you have dozens or hundreds of files, the advantages of a batch processing tool become very clear. It ensures the same rule is applied consistently to all selected files, reducing human omissions.

Effect Preview: From Scattered Numbers to a Unified Placeholder

Before Processing: Multiple TXT Files Awaiting Processing in the Folder

As seen in the pre-processing screenshot, the pending folder contains multiple txt files, with names including big_bang.txt, black_holes.txt, dark_energy.txt, dark_matter.txt, and galaxies.txt. Such files often have similar content structures but contain different specific numbers in each file.

image-Batch replacement across multiple text files,wildcard search and replace,regex batch replacement for TXT,text file content batch processing

Using the manual method would require opening these files one by one and then finding different numbers separately. The problem is you don't necessarily know what numbers are in each file, and even if you did, you would still have to perform the replacement operation multiple times.

Before Processing: Numbers Distributed in Different Locations Within a Single File

Opening black_holes.txt shows numbers like 10, 30 within the body text, interspersed within English paragraphs. The screenshot uses red boxes and arrows to highlight some of these numbers, indicating they are the targets for this batch find and replace.

image-Batch replacement across multiple text files,wildcard search and replace,regex batch replacement for TXT,text file content batch processing

The common characteristic of these contents is that they are "composed of digits," rather than being fixed to a specific value. Therefore, as long as you can tell the software to find all numbers, you don't need to list each specific value individually.

After Processing: Matched Numbers Are Replaced with AAA

After processing is complete, reviewing black_holes.txt again shows that the original numbers have become AAA. The screenshot shows multiple locations with AAA marked in green, indicating the replacement rule has been applied to various numbers in the file.

image-Batch replacement across multiple text files,wildcard search and replace,regex batch replacement for TXT,text file content batch processing

As seen from the results, batch replacement is not simply replacing a specified word, but rather matching content that meets the rule based on an expression. This is also the core value of wildcards and regular expressions in batch text processing.

Operation Steps: Batch Find and Replace Keywords in Text

Step One: Open the Corresponding Function in the Text Tool

After launching HeSoft Doc Batch Tool , first select Text Tool in the left function bar. This category includes various text processing capabilities, such as text conversion, HTML conversion, Markdown conversion, etc. The function needed this time is the first one: Find and replace keywords in text.

image-Batch replacement across multiple text files,wildcard search and replace,regex batch replacement for TXT,text file content batch processing

The purpose of selecting this function is to enable the software to enter a batch find-and-replace workflow for text file content. Compared to editing files individually in an editor, a batch tool first collects files uniformly, then sets rules uniformly, and finally processes them all at once.

Step Two: Add Files or Import Files from a Folder

After entering the function page, the interface top shows the current task is "Find and replace keywords in text." Step 1 of the process is "Select records to process." In the top right corner, you can see buttons for Add Files, Import Files from Folder, Clear, and More.

image-Batch replacement across multiple text files,wildcard search and replace,regex batch replacement for TXT,text file content batch processing

If files are scattered in different locations, you can add them individually via "Add Files"; if all txt files are in the same folder, using "Import Files from Folder" is more efficient. In the example, after importing, the table lists 5 records, including file name, path, extension, creation time, modification time, and other information.

The expected outcome of this step is: all text files whose content needs to be replaced appear in the list, and the record count matches expectations. The bottom of the screenshot shows the record count is 5, indicating this task will process 5 TXT files. After confirming the list is correct, click Next at the bottom.

Step Three: Set the Find Method to Use Formula for Fuzzy Text Search

Upon reaching Step 2, "Set Processing Options," first choose the find method. The screenshot shows two options: Precise text search, use formula for fuzzy text search. Since the goal here is to find all numbers, not a specific fixed string, select use formula for fuzzy text search.

image-Batch replacement across multiple text files,wildcard search and replace,regex batch replacement for TXT,text file content batch processing

"Use formula for fuzzy text search" here can be understood as a rule-based text search. For users familiar with search expressions, its usage concept is very close to regular expressions and wildcard matching: describe a category of text using a rule, then let the software automatically find it in multiple files.

Step Four: Enter the Find Rule \d+ and Replace Content AAA

In the "Keyword list to find" input field, enter:

\d+

In the "Replacement keyword list" input field, enter:

AAA

These two input fields have a one-to-one correspondence. The left side specifies what to find, and the right side specifies what to replace it with. \d+ indicates matching consecutive digits, and AAA is the replacement text. After setting this, any matching number segments in the files will be replaced with AAA.

The purpose of this step is to upgrade "replacing a specific number" to "replacing all content conforming to the numeric rule." For example, if numbers like 5, 10, 30, 100, 26000 appear in a file, they can all be processed by the same rule.

Step Five: Continue to Set the Save Location and Start Processing

The workflow at the top of the interface also shows Step 3 "Set save location" and Step 4 "Start processing." After completing the keyword options, continue clicking Next to set the save location for the processed files following the wizard. For safety, it is recommended to save the processing results to a new output folder.

After setting the save location, proceed to the start processing step. Upon execution, the software applies the same find-and-replace rule to multiple TXT files in the list. After processing is finished, you can open one or more files to check and confirm whether the original numbers have become AAA.

Key Points for Regex and Wildcards: Understand the Rules First, Then Execute in Batch

The key element in this case is \d+. Although it looks short, it can represent a multitude of possible numbers. Understanding its meaning helps you flexibly use similar rules in other scenarios.

  • \d: Matches a digit character.
  • +: Matches the preceding element one or more times.
  • \d+: Matches a segment of consecutive digits.

It should be noted that \d+ primarily matches consecutive digits. If the text contains numbers with commas, like "26,000," it might treat 26 and 000 as two separate number segments, resulting in an output like AAA,AAA. For such numbers with separators, if you want them replaced as a whole, you need to further adjust the expression based on the actual rule.

Furthermore, if you need to process dates, serial numbers, amounts, decimals, etc., you should first test the rules with a small sample of files. The efficiency of batch processing is high, but the prerequisite is accurate rules.

Common Questions and Precautions

1. Can multiple find-and-replace pairs be set simultaneously?

As seen from the "Keyword List" and "Replacement Keyword List" in the screenshot, the interface supports entering find and replace items in a list format. During actual use, ensure the content on the left and right sides corresponds accurately to avoid mismatches between find and replace items.

2. What happens if the replacement content is left empty?

The prompt on the right side states "Leaving blank means deletion," so if the replacement content is left empty, the matched content may be deleted. This can be used for batch text cleanup, but it is even more important to back up or test beforehand.

3. Will it affect file names?

This function's name is "Find and replace keywords in text." Judging from the interface and examples, the processing target is text file content, not file names. If you need to rename files in batches, you should use the tool related to file names within the software.

4. Can it process Word docx or doc files?

This article demonstrates TXT file processing under the Text Tool. If your files are Word documents, such as docx or doc, you should check the Word Tool category on the left side of the software and select a batch processing function suitable for Word document content.

5. What is the most important check before batch replacement?

The most important checks are the file list and the expression rule. The file list determines the processing scope, and the expression rule determines the replacement content. An incorrect setting in either could lead to results not meeting expectations.

Summary: Leave Repetitive Text Replacement to a Batch Processing Tool

Batch replacing similar content in multiple text files is a very typical office automation need. Using HeSoft Doc Batch Tool , you can first batch import TXT files, then use the formula for fuzzy text search to enter the \d+ rule, and finally uniformly replace the matched numbers with AAA. Compared to the manual, file-by-file find-and-replace method, this approach is faster, more stable, and more suitable for handling large volumes of files.

If you are organizing a batch of txt texts, log files, or draft materials and need to replace keywords within them according to rules, it is advisable to first prepare a test folder and perform a small-scale validation following the steps in this article. Once the results are confirmed to be correct, execute the batch process on the official files to significantly improve office efficiency while ensuring accuracy.


Keyword:Batch replacement across multiple text files , wildcard search and replace , regex batch replacement for TXT , text file content batch processing
Creation Time:2026-07-03 07:00:20

Disclaimer: All images, text, and video content on the website are for reference only and may not be the latest, correct, or accurate. In case of any dispute, please refer to the actual experience effect!

Related Articles

Don't see the feature you want?

Provide us with your feedback, and after evaluation, we will implement it for free!