How to use regular expressions to batch and fuzzily modify folder names, replacing the trailing numbers with specified text


Translation:EnglishFrançaisDeutschEspañol日本語한국어,Update Time:2026-06-30 07:12:26

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 a large number of folder names contain similar but not identical characters, manually renaming them one by one is prone to errors and wastes a lot of time. This article uses "batch replace the last three digits of folder names with -TEST" as an example to introduce how to use the "Find and replace keywords in folder names" feature in HeSoft Doc Batch Tool to perform fuzzy text searches using formulas, i.e., common wildcard or regular expression methods, to batch complete fuzzy modifications of folder names. The article includes before-and-after effects, specific operation steps, and notes, suitable for office scenarios that require organizing project directories, test directories, and numbered directories.

In daily office work, project archiving, material delivery, and test data organization, it's common to encounter a batch of folders with similar naming formats, but where a specific segment within them is not completely identical. For example, folder names might be numbered directories like INV4X812, ORD7A293, PO9C376, REQ8F194, SO2D705, which are combinations of letters and numbers. If you now want to uniformly replace the last three digits of these folders with -TEST, manually renaming them one by one might seem simple, but when the number of folders increases from a few to dozens or hundreds, it becomes a repetitive, inefficient, and error-prone task.

The problem this article aims to solve is: How to batch-modify many folder names fuzzily using wildcards or regular expressions. Here, we use the office software HeSoft Doc Batch Tool shown in the screenshots. Through the "Find and Replace Keywords in Folder Names" function under the "Folder Name" category, we can replace the patterned parts of folder names in one go. The search formula used in the example is \d{3}, which can match three consecutive digits; the replacement content is -TEST, ultimately achieving the effect of uniformly changing the trailing digits to a test identifier.

Applicable Scenarios: When is it suitable to use regular expressions for batch folder renaming?

Batch modifying folder names is not just about "replacing one fixed text with another fixed text." In real office environments, it's more common to encounter situations where "the names have a pattern, but the specific characters in each folder are different." Such cases are perfect for using wildcards, formulas, or regular expressions for fuzzy searching and replacing.

For instance, the following scenarios can all reference the method in this article:

  • Project directory number cleanup: Folder names contain project numbers, client numbers, or batch numbers that need to be uniformly replaced with new identifiers.
  • Batch renaming of test directories: Converting a batch of formal numbered directories into test directories, for example, by changing the trailing digits to -TEST.
  • Standardizing document archiving directories: Folder names have inconsistent dates, serial numbers, or version numbers that need to be processed according to a unified rule.
  • Directory preprocessing before batch file organization: Before processing office files like Word, Excel, PowerPoint, PDF, and images, standardize the outer folder names first to facilitate subsequent retrieval and archiving.
  • Merging materials from multiple departments: Folders submitted by different departments have similar but not entirely consistent naming conventions. They can first be unified through fuzzy replacement of directory names.

The positioning of HeSoft Doc Batch Tool is office software, with its core value lying in batch processing of files and folders to reduce repetitive work. For such renaming tasks that are "batch-oriented, rule-based, and prone to repetitive errors," using a tool is more stable than manual modification and is more suitable for long-term office workflows.

Effect Preview: Folder name changes before and after processing

Before Processing: Folder names end with different three-digit numbers

From the pre-processing screenshot, you can see there are 5 folders in the current directory, named INV4X812, ORD7A293, PO9C376, REQ8F194, SO2D705. The first half of these names consists of a mix of letters and numbers, all ending with three digits, but the specific numbers are different for each folder.

If using ordinary "fixed text replacement," you would need to process different content like 812, 293, 376, 194, 705 individually; regular expressions can view these varying digits as a single pattern, i.e., "three consecutive digits." This is the key to fuzzily batch-renaming folders.

image-Batch rename folders,rename folders with regular expressions,batch replace folder names

After Processing: The trailing three-digit numbers are uniformly replaced with -TEST

The post-processing screenshot shows the original 5 folder names have been batch-modified to INV4X-TEST, ORD7A-TEST, PO9C-TEST, REQ8F-TEST, SO2D-TEST. That is to say, the trailing three-digit numbers in the original names were uniformly replaced with -TEST.

This result indicates the software did not just replace one specific fixed number, but batch-matched all qualifying character segments based on the set formula. For scenarios with many folders and different numbers but a consistent format, this processing approach can significantly reduce repetitive operations.

image-Batch rename folders,rename folders with regular expressions,batch replace folder names

Operation Steps: Using HeSoft Doc Batch Tool to Fuzzily Replace Folder Names in Batch

Step 1: Enter the "Folder Name" tool category and select the find-and-replace function

After opening HeSoft Doc Batch Tool , you can see multiple office processing categories in the left navigation bar, such as File Name, Folder Name, File Organization, Word Tools, Excel Tools, PowerPoint Tools, PDF Tools, Text Tools, Image Tools, etc. This article deals with folder names, so you need to enter the Folder Name category on the left.

Under the Folder Name category, the interface displays several function cards related to directory renaming, including "Find and Replace Keywords in Folder Names," "Insert Text into Folder Names," "Add Prefix and Suffix to Folder Names," "Change Folder Name Case," "Delete Text from Folder Names," and more. Based on the needs of this article, we want to replace patterned numbers in folder names with specified text, so select Find and Replace Keywords in Folder Names.

The purpose of this step is to enter the correct batch processing module. After selecting this function, you can subsequently add multiple folders and set the content to find and the content to replace with.

image-Batch rename folders,rename folders with regular expressions,batch replace folder names

Step 2: Add the folders that need processing, and confirm the list records are correct

After entering the "Find and Replace Keywords in Folder Names" function, you can see operation buttons like Add Folders, Clear, and More at the top of the interface. Here, you need to click "Add Folders" to add the folders you want to batch-rename into the processing list.

As seen in the screenshot, the software has already added 5 folders to the list, displaying sequence numbers, names, paths, creation time, modification time, and an operation column. The example paths are under D:\test\, with folder names being INV4X812, ORD7A293, PO9C376, REQ8F194, SO2D705. The summary at the bottom shows a record count of 5, indicating that 5 folder records will be processed this time.

At this step, it is advisable to carefully check two things: first, whether the folders in the list are all the directories that need renaming this time; second, whether the paths are correct, to avoid mistakenly adding other directories to the task. After confirming everything is correct, click Next at the bottom of the interface to proceed to the processing option settings.

image-Batch rename folders,rename folders with regular expressions,batch replace folder names

Step 3: Select formula-based fuzzy text search, enter the regular expression and replacement content

After entering the second step, "Set Processing Options," you need to set the search mode and replacement rules. In the screenshot, the selected option in the "Search Mode" area is Use Formula for Fuzzy Text Search. This option is suitable for handling situations where "the content is not fixed but the format has a pattern," which is often referred to as wildcard or regular expression batch matching.

In the "Keyword List to Find," enter:

\d{3}

A simple understanding of its meaning here is: find 3 consecutive digits. The example folder names all happen to end with exactly three digits, such as 812, 293, 376, 194, 705, so all can be matched by this formula.

In the "Replacement Keyword List" on the right side, enter:

-TEST

With this setup, the software will replace the matched three consecutive digits in each folder name with -TEST. Taking INV4X812 as an example, 812 will be replaced with -TEST, resulting in INV4X-TEST; taking ORD7A293 as an example, 293 will be replaced with -TEST, resulting in ORD7A-TEST.

Once the settings are complete, click Next at the bottom. The progress bar at the top shows subsequent steps for "Set Save Location" and "Start Processing"; just continue following the wizard to complete them.

image-Batch rename folders,rename folders with regular expressions,batch replace folder names

Step 4: Continue following the wizard to finish setting the save location and start processing

The progress bar in the screenshot shows this function uses a step-by-step wizard operation: the first step is to select the records needing processing, the second is to set processing options, the third is to set the save location, and the fourth is to start processing. Although the screenshots in this article focus on the first three key configuration interfaces, it can be reasonably inferred from the progress bar that after completing the regex replacement rule settings, you need to proceed to setting the save location and, after confirming everything is correct, start processing.

For folder renaming tasks, it is recommended to double-check the replacement rules before formal processing, especially whether the regular expression is too broad. Execute the batch processing only after confirmation. After processing is complete, you can go back to File Explorer to check if the folder names have been changed to the target format.

Rule Explanation: Why \d{3} can batch-match digits in different folder names

The core of this example lies in \d{3}. In common regular expressions, \d represents a digit character, and {3} indicates it appears exactly 3 consecutive times. Therefore, \d{3} means "three consecutive digits."

This type of rule is very suitable for processing content like serial numbers, sequence numbers, and batch numbers. For example:

  • The 812 in INV4X812 will be matched.
  • The 293 in ORD7A293 will be matched.
  • The 376 in PO9C376 will be matched.
  • The 194 in REQ8F194 will be matched.
  • The 705 in SO2D705 will be matched.

Without using fuzzy search, you would need to input and replace these numbers one by one; by using formula-based fuzzy search, as long as these numbers share a common pattern, you can complete batch folder renaming in one go. This is also where the value of the office software's batch processing capability lies.

Common Problems and Precautions

1. Will the regular expression match digits in the middle of a folder name?

Based on the results in this example, the trailing three-digit numbers in the names were replaced with -TEST. If a folder name also contains three consecutive digits elsewhere in the middle, caution is needed when using \d{3}, as it might match all qualifying three-digit numbers. Before formal processing, it's advisable to test the rule with a small sample first to confirm the results meet expectations.

2. Why check the added folder list first?

Batch processing is highly efficient, but it also means that if the task list includes folders that shouldn't be processed, errors will be quickly amplified. Therefore, before clicking next, you should check the names, paths, and record count. The summary record count in the screenshot is 5, with clear processing targets, making it suitable to proceed.

3. What is the difference between "Exact Text Search" and "Use Formula for Fuzzy Text Search"?

As seen in the interface, the search modes include "Exact Text Search" and "Use Formula for Fuzzy Text Search." If you want to replace fixed content, such as changing all folder names from "old project" to "new project," you can use exact text search; if you want to replace content that is not fixed but follows a pattern, such as three-digit numbers, dates, or batch numbers, then using formula-based fuzzy text search is more suitable.

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

The right area of the screenshot hints "Leaving it blank means deletion." Therefore, if no content is entered in the replacement keyword list, it might mean the found content will be deleted. The goal of this article is to replace numbers with -TEST, so you need to explicitly input the replacement text on the right side to avoid accidental deletion.

5. Is a backup needed before batch renaming?

For important project materials, it is recommended to keep a backup before batch renaming, or copy a small subset of folders for testing first. Especially when using regular expressions, a rule written too broadly might affect unintended characters. Testing first and then executing in batch is a more reliable office processing habit.

Conclusion: Let rules handle the repetitive folder renaming work using office software

This article demonstrated how to use HeSoft Doc Batch Tool through its "Find and Replace Keywords in Folder Names" function, combined with a formula-based fuzzy search rule like \d{3}, to batch-replace the trailing three digits in multiple folder names with -TEST. Before processing, the folder names were different; after processing, all directories were modified according to a unified naming rule.

For users who frequently need to organize folders, standardize directory names in batches, or handle project numbers or test directories, this method can significantly reduce the time spent on manual renaming and lower the probability of missed or wrong changes. It is recommended that when encountering a large number of similar folder names, you first analyze the naming pattern, then use a batch processing tool to set up search and replacement rules, letting the office software handle the repetitive work.


Keyword:Batch rename folders , rename folders with regular expressions , batch replace folder names
Creation Time:2026-06-30 07:12:11

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!