When the file name prefix contains numbers, you don't need to manually create directories like 101, 102, 103 and then move files one by one. Through the HeSoft Doc Batch Tool "Classify files by file name" function, select custom regular expression and enter ^\d{3} to extract the first 3 digits of the file name as the classification basis, and batch organize a large number of txt, doc, docx, xlsx, pdf and other files into corresponding folders, suitable for archiving project materials, customer files, and numbered documents.
Many office files are not without patterns; rather, the patterns are hidden in the file names. For example, in the same directory, the file names are 101LON05417.txt, 101SYD26137.txt, 102NYC53821.txt, 103PAR08578.txt. From a manual perspective, the organization method is simple: put files starting with 101 into the 101 folder, files starting with 102 into the 102 folder, and files starting with 103 into the 103 folder. However, if the number of files is large, manual selection, cutting, and pasting become repetitive labor.
This article introduces a method more suitable for batch office file organization: using HeSoft Doc Batch Tool , through the "Classify files by file name" function, combined with wildcard thinking and regular expressions, to automatically group files with the same starting digits in their names together. The example uses txt files, but the method is not limited to txt; as long as the file naming rules are consistent, files like docx, doc, xlsx, xls, pdf, jpg can also be organized using the same logic.
Applicable Scenario: File Names with Numbers Enable Automated Organization
This batch classification method is particularly suitable for the following work scenarios:
- Project File Archiving: The first few characters of the file name are the project number, requiring files to be split into folders by project.
- Customer Data Organization: The customer number is written at the beginning of the file name, followed by contracts, quotes, scanned copies, or spreadsheets.
- Regional or Store Data Aggregation: For instance, 101, 102, 103 represent different regions, warehouses, or stores.
- Batch Grouping of Exported Files: System-exported files have uniform naming but are all piled in one directory and need secondary organization.
- Historical Directory Cleanup: Documents accumulated over many years need to be re-archived by file name prefix.
The problem with manual classification is that the more files there are, the more likely omissions and misplacements occur. The value of office software is precisely demonstrated in such repetitive tasks. HeSoft Doc Batch Tool combines "recognition rules" with "batch execution," making the process of organizing large numbers of files more controllable.
Preview of Effect: All Files Mixed Together Before Processing
In the directory before processing, files are displayed by name in a single list. The red annotations in the screenshot show the pattern of the first 3 digits of the file names: some are 101, some are 102, and some are 103. Although the following letters and numbers differ, the starting number can serve as the basis for classification.

If processed manually, one would need to first select all files starting with 101 and move them to the 101 folder; then select files starting with 102 and move them to the 102 folder; and then continue processing 103. This process is not only multi-step but also prone to selection errors when file names are similar. By using regular expressions, you only need to tell the software to "extract the first 3 digits of the file name," and the rest of the classification actions can be completed in batch.
Preview of Effect: Folders Generated by Number After Processing
After processing is complete, you can see in the output that three folders have been created: 101, 102, 103. Each folder corresponds to a file name prefix, and the previously mixed files are now grouped and placed within.

This organizational result is very helpful for subsequent work. For example, if you need to package and send project files for 101, you just need to open the 101 folder; if you need to verify materials numbered 102, you don't have to search through all files. The clearer the classification, the more time is saved for later searching, reviewing, sharing, and backing up.
Operation Steps: The Complete Process from Importing Files to Regex Classification
Step One: Find the Classify by File Name Function in File Organizer
After opening HeSoft Doc Batch Tool , the left navigation contains multiple tool categories, including File Name, Folder Name, File Organizer, Word Tools, Excel Tools, PDF Tools, etc. The current task is batch organizing file locations, so enter File Organizer.

On the File Organizer page, select Classify files by file name. From the function name, it's clear that it does not modify file names or convert file formats, but rather organizes files by rules within their names. For sorting into folders by prefixes like 101, 102, 103, this function is a perfect fit.
Step Two: Import the File List to be Processed
After entering "Classify files by file name," the first step is to select the records to be processed. The top of the interface offers Add files and Import files from folder. If the files are already gathered in a specific directory, it is recommended to use "Import files from folder" to reduce the operation of selecting files one by one.

After files are imported, the list displays information such as name, path, extension, creation time, and modification time. As seen in the screenshot, the imported file names all contain leading numbers, and the paths also point to the same directory. The bottom shows the record count as 20, indicating this batch operation will process 20 records. After confirming there are no errors, click Next below the page.
Step Three: Extract the First 3 Digits Using a Custom Regular Expression
The second step leads to "Set processing options." There are multiple classification methods here, such as by the first character, by the first number, by the first few characters, etc. Since this example requires matching exactly 3 consecutive digits at the beginning of the file name, selecting Classify by custom regular expression is more intuitive and flexible.

Enter the following in the regular expression input box:
^\d{3}
This expression can be understood as "starting from the beginning of the file name, match 3 consecutive digits." It will identify 101LON05417.txt as 101, 102SYD15496.txt as 102, and 103LON28360.txt as 103. The classification names come from the regex match results, thus eventually forming corresponding classification folders.
If your file rules are not 3 digits, you can also adjust it according to the actual situation. For example, if the start is a 4-digit order number, you can change the quantity to 4; if the start is a fixed letter plus numbers, you need to set a more fitting expression based on the file name structure. It is recommended to test with a few files first to confirm the match meets expectations before batch processing all files.
Step Four: Confirm Letter Case Handling
The screenshot also shows the "Letter case conversion" area, including Default, Convert to uppercase, and Convert to lowercase. The classification basis for the current example is numbers, so keeping the default is fine. If you want to classify by an English prefix, such as abc, ABC, Abc, you need to decide whether to unify the case based on company naming conventions. Unifying case can prevent the same type of files from being scattered into different folders due to different letter cases.
Step Five: Set the Save Location and Execute Processing
After clicking Next, the process will enter Set save location. It is recommended to choose a new output directory to distinguish it from the original one. If processing important files, keep the original folder untouched first, and decide whether to replace or archive it after confirming the classification results.
Finally, enter the Start processing stage and execute according to the on-screen prompts. After processing is complete, open the save location, and you will see classified folders named after the match results, such as 101, 102, 103. Check these folders individually to confirm that the files have been categorized according to their starting digits.
Common Questions and Considerations
What is the relationship between Regex and Wildcards?
Many users tend to refer to "matching file names by rules" collectively as wildcard matching. Regular expressions can be seen as a more precise and flexible way of writing rules. The ^\d{3} in this example is more general than simply entering 101, 102, 103 because it can automatically recognize any 3 starting digits without specifying each classification number individually.
Must the classification basis be at the beginning of the file name?
This example uses the first 3 digits because that is the pattern of the file names in the screenshot. If your classification field is in the middle or at the end, you can also use corresponding regular expressions for matching. In practice, the key is to find a part of the file name that is stable, unique, and suitable for use as a folder name.
Can files with different extensions be processed at once?
This can be understood by the file name rules. As long as the imported file names meet the matching conditions, different extensions generally do not affect the classification approach. For example, if a directory contains 101Contract.docx, 101Checklist.xlsx, and 101Scan.pdf simultaneously, they can all be grouped into the same category as long as they start with 101.
Why check the import list before processing?
The efficiency of batch tools comes from processing multiple files at once, so the accuracy of the import list is very important. If irrelevant files are mistakenly imported, the regular expression may also process them. Checking names, paths, and record counts before formal execution is an effective step to avoid operational errors.
Summary: Hand File Name Rules to Software to Reduce Repetitive Organization
Batch classification by the starting digits of file names is a very typical repetitive task in office file management. With HeSoft Doc Batch Tool , import the files first, then select "Classify by custom regular expression," enter ^\d{3}, and it can automatically organize files starting with 101, 102, 103, etc. into corresponding folders.
If your work often involves organizing customer data, project documents, system export files, or numbered files, try observing file name patterns first, and then use batch processing tools to complete the classification. This not only reduces manual dragging but also lowers the probability of misfiling, making file archiving more standardized and efficient.