How to automatically archive a large number of txt files into folders 101, 102, 103 based on the first three digits of their numbering


Translation:EnglishFrançaisDeutschEspañol日本語한국어,Update Time:2026-06-28 06:51:18

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 a large number of txt files starting with numbers, if you are still manually searching for 101, 102, 103 and dragging them into folders one by one, it will waste a lot of time. This article introduces a more efficient office file organization method: use the "classify files by filename" function of HeSoft Doc Batch Tool , after importing files, select custom regular expression, enter the rule to extract the first three digits of the filename, and you can batch generate numbered folders and complete automatic archiving.

When many enterprises or teams export system data, they often obtain a batch of files with similar naming rules. For example, the file names in this case include 101LON05417.txt, 101LON09060.txt, 102LON48897.txt, 102NYC53821.txt, 103LON23328.txt, etc. The 101, 102, 103 at the beginning of the file names are clearly category numbers, but these files are often all piled up in one directory after export. To subsequently count, compress, send, or archive them, files with the same number must first be placed together.

If you are only dealing with a dozen or so files, manual organization is not a big problem; however, in real office scenarios, the number of files often reaches hundreds or even thousands. Manual archiving encounters several issues: constantly checking file name prefixes, repeatedly creating new folders, selecting files in batches, and worrying about accidentally dragging 102 files into the 101 folder. For tasks with such clear rules but repetitive operations, it is more suitable to use batch processing office software.

This article will demonstrate how to use HeSoft Doc Batch Tool to automatically archive many txt files into corresponding folders based on the first three digits of the file name. Although the example uses txt files, it is equally suitable for organizing Word documents docx/doc, Excel spreadsheets xlsx/xls, PDF materials, images, or other common office files by number.

Applicable Scenarios: Why Check File Name Prefixes for Batch File Archiving

Archiving by file name prefix is suitable for situations where the file name itself already contains classification information. Typical scenarios include:

  • Report files exported from a system, where the first three digits of the file name represent an institution code.
  • Project documents named starting with a project number, requiring sorting into folders by project number.
  • Customer materials starting with a customer code, requiring centralized storage by customer code.
  • Logistics, order, inspection, or experimental data starting with a batch number, requiring archiving by batch.
  • Log or text files starting with a device number, requiring classification by device number.

The commonality in these scenarios is that the classification basis is not the file extension, but a segment of characters in the file name. Using "classify by extension" can only distinguish txt, docx, pdf, but cannot separate business numbers like 101, 102, 103. Therefore, this example chooses "classify files by file name" and then uses a regular expression to extract the first three digits.

Effect Preview: From a Mixed File List to Numbered Folders

Before Processing: All numbered files are mixed in the same directory

The screenshot before processing shows a batch of txt files in the current folder. They have the same extension and similar modification times, but different file name prefixes. The red markings emphasize the 101, 102, 103 at the beginning of the file names, which are exactly the classification basis we want to extract.

image-Batch classification of TXT files,classify by the first three characters of the file names,batch archive files,organize files using regular expressions,create folders by number

If processed manually, one would typically need to first create 101, 102, 103 folders, then sort by name, select files starting with 101 and drag them into the 101 folder, then select files starting with 102 and drag them into the 102 folder. This process seems simple, but the operational cost rises quickly when more numbers exist simultaneously in the folder.

After Processing: Files with the same number are automatically placed together

After processing is complete, 101, 102, and 103 folders appear in the directory. That is, the software created the corresponding classification results based on the numbers matched from the beginning of the file names. Afterwards, you just need to enter the corresponding folder to view all files under that same number.

image-Batch classification of TXT files,classify by the first three characters of the file names,batch archive files,organize files using regular expressions,create folders by number

This result is particularly suitable for archiving and delivery. For example, you can directly compress the 101 folder and send it to the corresponding department, or save the 102 folder as an independent batch, avoiding subsequent repeated filtering.

Operation Steps: Batch organizing txt files by the first three digits

Step 1: Open the classify by file name function in File Organizer

After launching HeSoft Doc Batch Tool , you can see multiple tool categories on the left, including File Name, Folder Name, File Organizer, Word Tools, Excel Tools, PowerPoint Tools, PDF Tools, etc. This time the goal is to organize file locations, so enter "File Organizer".

On the File Organizer page, select "Classify files by file name". In the screenshot, this function is the first in the tool list, indicating it is specifically used for batch-classifying files according to file name rules.

image-Batch classification of TXT files,classify by the first three characters of the file names,batch archive files,organize files using regular expressions,create folders by number

After this step is completed, the software will enter the corresponding wizard-style processing flow. The interface breaks the task down into stages: selecting records, setting processing options, setting save location, and starting processing, suitable for users unfamiliar with regular expressions to complete step by step.

Step 2: Add files or import files from a folder

After entering the task interface, the first step is "Select records to process". There are buttons such as "Add File", "Import Files from Folder", "Clear", and "More" at the top right of the interface. For scenarios with a large number of files, using "Import Files from Folder" is usually more convenient, as it can add files from the target directory to the list at once.

image-Batch classification of TXT files,classify by the first three characters of the file names,batch archive files,organize files using regular expressions,create folders by number

After importing, the table will list the file name, path, extension, creation time, and modification time. In the example, the file path is in the D:\test directory, the extension is txt, and the record count shown at the bottom is 20. This check is very important because subsequent batch operations will act on the records in the list. After confirming the files are imported correctly, click "Next" at the bottom of the page.

Step 3: Choose the regular expression classification method

After entering "Set processing options", the page displays various classification methods. If you only need to classify by the first character, you can choose that; if you want to classify by a fixed length at the beginning, you can also use classifying by the first few characters. However, this example emphasizes using a more flexible and reusable rule, so "Classify by custom regular expression" is chosen.

image-Batch classification of TXT files,classify by the first three characters of the file names,batch archive files,organize files using regular expressions,create folders by number

Enter ^\d{3} in the regular expression input box. The function of this rule is to extract three consecutive digits from the very beginning of the file name. For 101LON05417.txt, the extraction result is 101; for 102SYD15496.txt, the result is 102; for 103LON28360.txt, the result is 103. The software will use the extraction results as the category names, thereby automatically grouping the files.

This step can also be understood as "using a rule to tell the software: where the folder name should come from within the file name." Compared to manually entering multiple numbers, the advantage of a regular expression is that you only write the rule once, and it can adapt to all files that conform to the naming convention. If another batch of txt files starting with 101, 102, 103 is exported later, you can continue to use the same expression.

Step 4: Set the output location and start batch archiving

After completing the processing options, click "Next" to enter "Set save location". It is recommended to set the save location to a new output folder, such as a directory specifically for this archiving task. This way, after processing is complete, you can clearly distinguish between the original files and the organized results, making it easy to check if all archiving was successful.

Finally, enter the "Start Processing" stage. The software will read the file names from the imported list one by one, match the first three digits based on the regular expression, and place files with the same number into the same folder. After processing is finished, you will see the categorized folders like 101, 102, 103 in the output directory.

FAQ and Notes

1. Why not manually search for 101, 102, 103?

Manual searching is suitable for temporarily processing a small number of files, but not for long-term repeated use. Every time a new number is added or the number of files increases, you have to search and drag again. Regular expression classification only requires setting the rule, and the software can execute it in batches, making it more suitable for office automation organization.

2. Must the first three digits of the file name all be numbers?

This example uses ^\d{3}, thus requiring the file name to start with three digits. If your file names are like A01, B02 with a letter followed by numbers, you need to replace it with a regular expression that suits you. The regex rule must match the actual naming structure for the classification results to be accurate.

3. Is a backup necessary before classification?

Before batch processing files, it is recommended to keep the original files or select an independent save location. Especially when setting up the rule for the first time, it's safer to test with a small number of samples first. After confirming the output folder and classification results are correct, proceed to process the full directory.

4. Can this be used for non-txt files?

Yes. Classifying by file name focuses on the naming rule, not the file content. As long as the file name contains extractable numbers, files like docx, doc, xlsx, xls, pptx, pdf, jpg, png can all be organized using a similar method.

Summary: Turning numbered archiving from manual dragging into batch processing

Archiving a large number of txt files by number is essentially an office task with clear rules but high repetitiveness. The "Classify files by file name" function provided by HeSoft Doc Batch Tool can extract the first three digits of a file name and automatically generate corresponding folders. By selecting "Classify by custom regular expression" and entering ^\d{3}, files starting with 101, 102, 103 can be quickly organized together.

If your daily work often involves organizing system-exported text files, contract documents, spreadsheet reports, or PDF materials, consider adding this method of batch classification by file name using regex to your fixed workflow. It can significantly reduce repetitive labor, make file archiving more standardized, and make subsequent searching and delivery more efficient.


Keyword:Batch classification of TXT files , classify by the first three characters of the file names , batch archive files , organize files using regular expressions , create folders by number
Creation Time:2026-06-28 06:50:52

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!