Too many files? How to group them by name rules? Use regex to batch sort them into corresponding folders


TranslationEnglishFrançaisDeutschEspañol日本語한국어Update Time2026-06-29 06:56:55

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!

Faced with many office files named similarly, if the first few characters of a file name represent a project, client, or category number, you can use a regular expression to automatically extract the number and group them. This article demonstrates in HeSoft Doc Batch Tool , by importing files with "Classify files by file name", selecting "Classify by custom regular expression", and entering ^\d{3}, files starting with 101, 102, 103 are batch organized into corresponding folders, reducing the repetitive labor of manual filtering and moving files.

When the number of files grows large, organizing them becomes a tedious yet necessary task. Especially after batch downloading files from business systems, devices, email attachments, or collaboration platforms, filenames often contain fixed numbers, such as 101, 102, 103, etc. During manual organization, we usually look at the filename prefix first, then decide which folder to place it in. Repeating this action dozens of times is acceptable, but hundreds of times is a huge waste of time.

This article introduces a batch organization method more suitable for office scenarios: using HeSoft Doc Batch Tool to automatically group files based on rules in filenames. In the example, we will use the regular expression ^\d{3} to extract the first 3 digits of the filename and group files starting with the same digits together. Whether the files are txt text, Word documents (docx/doc), Excel spreadsheets (xlsx/xls), or PDFs, as long as the filenames follow the rule, you can refer to this approach.

Applicable Scenario: Batch Grouping When Filenames Have Fixed Rules

Grouping by naming rules focuses not on the file content, but on the filename itself. As long as the filename reflects classification information, you can use tools for batch organization. The following situations are very common:

  • Number at the beginning of the filename: Such as 101LON05417.txt, 102NYC53821.txt, needing to be grouped by 101, 102.
  • Customer code as a prefix: Such as A001Contract.docx, A001Invoice.pdf, B002Quote.xlsx, needing to be archived by customer code.
  • Unified project number naming: The project number is in the first few characters of the filename, followed by different types of documents.
  • System-exported files: Filenames have a fixed structure, but all are exported to the same directory.
  • Consolidating multi-format documents: Under the same classification, there are documents, spreadsheets, scanned copies, and text files.

For these types of tasks, the positioning of HeSoft Doc Batch Tool is very clear: it is a batch processing software for office files, helping users reduce repetitive labor. You don't need to create new folders one by one or judge file ownership individually; instead, you configure the naming rules and let the software organize according to them.

Effect Preview: File Naming Patterns Before Processing

The image below shows the file list before processing. You can see that all files are mixed in the same directory, but the first 3 digits of the filenames carry classification significance. Red annotations point out these prefixes: 101, 102, and 103. These are the basis for the subsequent categorization.

image-Group files by naming rules,organize files with regular expressions,and move files to folders in bulk

If you organize using the traditional method, you would first filter for files starting with 101 and move them, then filter for 102 and move them, and finally process 103. As the number of categories increases, manual operation becomes more and more tedious. However, a regular expression can clearly define the task of "identifying the first 3 digits" in one go, applicable to all files that meet the rule.

Effect Preview: Files Entering Corresponding Category Folders After Processing

After processing, folders named with the classification results appear in the directory. In the example, three folders—101, 102, and 103—are generated, indicating that the software has completed the classification based on the digits at the beginning of the filenames.

image-Group files by naming rules,organize files with regular expressions,and move files to folders in bulk

This result is very suitable for subsequent management. For example, if you need to view only files related to the number 103, you can directly enter the 103 folder. If you need to compress the 101 documents to send to a colleague, files from 102 or 103 won't get mixed in. The purpose of file organization is not just to "look tidy," but to make subsequent searching and collaboration more efficient.

Operation Steps: Using Custom Regular Expressions for Batch File Organization

Step One: Open the File Organization Function

After launching HeSoft Doc Batch Tool , find File Organization in the left navigation bar. The right functional area displays multiple cards related to file organization. For this task, select Classify files by filename.

image-Group files by naming rules,organize files with regular expressions,and move files to folders in bulk

From the screenshot, you can see the function's description is to batch classify all files by filename. That is to say, it focuses on "what classification information is contained in the filename," which is very suitable for the requirement of archiving by prefix number as in this article.

Step Two: Import the Files to be Classified

After entering the function, the first step is to select the records to be processed. At the top of the interface, there are operation entries like Add Files, Import Files from Folder, and Clear. If all files to be organized are in one folder, using "Import Files from Folder" is faster; if you only want to process some of them, you can choose them via "Add Files".

image-Group files by naming rules,organize files with regular expressions,and move files to folders in bulk

After the import is complete, the files are listed in a table. You can check the file name, path, extension, creation time, and modification time in the table. In the screenshot example, the files are located in the D:\test\ directory, with a txt extension, and the record count is 20. After confirming the records to be processed are correct, click the Next button at the bottom.

Step Three: Choose to Classify by Custom Regular Expression

After entering "Set Processing Options," you can see multiple classification methods. For simple rules, you can choose to classify by the first character, the first digit, or the first few characters. However, this example aims to explicitly match the consecutive 3 digits at the beginning of the filename, so you should select Classify by Custom Regular Expression.

image-Group files by naming rules,organize files with regular expressions,and move files to folders in bulk

Then enter the following in the "Regular Expression" input box:

^\d{3}

This expression is very suitable for the current example:

  • ^ anchors the match to the start of the filename, preventing the matching of other digits later on.
  • \d represents a numeric digit.
  • {3} means match exactly 3 digits.

Therefore, the file 101TYO08638.txt will be identified as class 101, 102TYO76564.txt as class 102, and 103SYD61045.txt as class 103. The software will organize the files into corresponding locations based on the recognized classification values.

Step Four: Keep the Default Case Settings as Needed

At the bottom of the same page, there is a "Letter Case Conversion" setting. Since the classification field in this example is numeric, the default setting is fine. If your file classification prefix includes English letters, for example, abc001, ABC002, whether to convert the case will affect the classification result. To avoid splitting files of the same category into multiple folders, it is recommended to unify the naming rules before processing or choose the appropriate case handling method here.

Step Five: Set the Save Location and Start Processing

After clicking Next, the process moves to "Set Save Location." It is recommended to save the processing results to a new directory. This makes it easier to compare the before and after effects and also protects the original files. After confirming the save location, proceed to "Start Processing."

When the batch processing is complete, open the output directory to check the results. Normally, you will see folders like 101, 102, 103, and files with the same prefix will be concentrated in their corresponding folders. If the processing result meets expectations, you can use these classification folders for subsequent archiving, backup, compression, or sending.

Frequently Asked Questions and Notes

1. Why use ^\d{3} instead of directly entering 101?

If you only enter the fixed 101, it can only target one specific number. The advantage of using ^\d{3} is that it can automatically match any starting 3 digits, including 101, 102, 103, and future numbers like 104, 205, 999, etc. This makes the rule more universal and more suitable for batch processing.

2. What if the filename prefix is not 3 digits?

You can adjust the expression according to the actual naming rules. For example, if the first 2 characters are the classification number, change it to match 2 digits; if the first 4 are the year or project number, match 4 digits. The core idea is to have the expression accurately extract the classification field, rather than rigidly copying the example.

3. Will digits in the middle of the filename affect the process?

This example uses ^, which means it only matches from the start of the filename. Therefore, even if there are other digits later on, they will not be used as a basis for classification. This is also one of the advantages of using regular expressions: you can explicitly limit the matching position, reducing misclassification.

4. What preparations need to be made before batch classification?

It is recommended to do three things first: First, confirm that all files to be processed have been imported; second, confirm that the filename rules are consistent; third, back up important data first or output to a new directory. Batch processing can greatly improve efficiency, but a rule setting error can also affect results in bulk, so preliminary checks are very important.

5. Is this suitable for mixed Word, Excel, and PDF files?

Yes, it is. This scenario classifies by filename, not by file content. As long as filenames start with the same rule, 101Contract.docx, 101Details.xlsx, and 101Scan.pdf can be grouped into the same category. For actual office document archiving, this cross-format organization capability is very practical.

Summary: Improve File Organization Efficiency with Regex Rules

When a large number of files need to be grouped by naming rules, the most important thing is to find a stable classification field. In this article's example, the first 3 digits of the filename are the classification field. By selecting "Classify files by filename" in HeSoft Doc Batch Tool and using the custom regular expression ^\d{3}, files starting with 101, 102, 103, etc., can be batch-organized into corresponding folders.

Compared to manually filtering and moving files, this method is much more suitable for handling a large volume of office files, especially for project materials, client documents, system-exported files, and historical file archiving. It is recommended that the next time you organize files, you first observe if there is a pattern in the filenames. If there is, let the batch processing tool complete the repetitive operations for you, saving your time for more important tasks.


KeywordGroup files by naming rules , organize files with regular expressions , and move files to folders in bulk
Creation Time2026-06-29 06:56:30

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!