Operation method for automatically sorting a large number of files into folders based on the three-digit code in the middle of the file name


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

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!

Many office files embed city codes, project codes, or department codes in file names, such as LON in 128LON75957.txt. If these codes are within a fixed character range, they can be automatically identified and classified through HeSoft Doc Batch Tool . This article focuses on the requirement of "batch sorting by the middle three-character code in file names," explaining the effects before and after processing, specific setup methods in the software, as well as considerations such as range input, case sensitivity, and file naming rules, helping users quickly complete batch archiving.

In enterprise office, data delivery, financial archiving, or project document organization, you often receive a batch of files with similar name structures. For example, in a group of txt files, the first three characters of the filename are a numeric ID, the middle three are a city or region code, followed by another string of numbers. The filenames look very regular, but if you need to put all LON files together, all NYC files together, and all PAR files together, manual sorting is still quite troublesome.

This article introduces a more efficient approach: using office software HeSoft Doc Batch Tool to automatically classify files based on characters within a fixed range in the filename. In the example, the classification is based on characters 4 through 6 of the filename, which are three-letter codes like LON, NYC, PAR, SYD, TYO. The software generates corresponding folders based on these characters and groups files with the same code together. For users who need to batch process txt, doc, docx, xls, xlsx, pdf, and other files, this method can significantly reduce manual operation time.

Applicable Scenario: Typical Office Needs for Archiving by Middle Code

Classifying by the middle three characters of a filename is suitable for all materials with a "fixed filename structure." For example, files exported from a logistics system may contain city codes, reports from a sales system may contain region codes, project materials may contain project team abbreviations, and customer service or after-sales materials may contain branch codes. If these codes appear in the same position within each filename, batch archiving can be achieved by extracting from a fixed range.

Using this example, in the filename "128LON75957.txt," the first three characters "128" are a prefix, characters 4 through 6 "LON" are the classification code, and the following "75957" is a suffix. Similarly, "TYO" in "213TYO11946.txt," "SYD" in "230SYD60610.txt," and "PAR" in "378PAR56483.txt" can all serve as the basis for automatic classification.

This method is particularly suitable for roles that require frequent processing of large volumes of files, such as administrative staff organizing notification attachments, financial personnel archiving reimbursement documents by department, operations staff splitting data files by city, and project assistants organizing Word documents and PDFs by project code. As long as the naming convention is stable, there is no need to open or move files one by one.

Result Preview: Files Piled in One Directory Before Classification

The image below shows the state before processing. All files are in the same directory, with a txt extension, and filenames containing three-letter English codes such as LON, TYO, SYD, PAR. Red markings and arrows emphasize the location of these codes, which is the content to be extracted for this automatic classification.

image-File name middle character classification,batch folder categorization,automatic file organization,file archiving by code,batch office file processing

Without tools, a user would need to examine each filename, create folders based on the codes, and then drag and drop files into the corresponding directories one by one. This process seems simple, but with a large number of files, it becomes very time-consuming and may lead to archiving errors due to misread codes or dragging files into the wrong folders.

Result Preview: Multiple Code Folders Formed After Classification

After processing is complete, the software generates folders based on the extracted three-character codes. In the example, you can see that five folders—LON, NYC, PAR, SYD, TYO—have appeared in the destination location. Files with the same code are placed into the same folder, facilitating subsequent statistics, packaging, forwarding, or long-term archiving.

image-File name middle character classification,batch folder categorization,automatic file organization,file archiving by code,batch office file processing

The advantage of this output result is its clear structure and intuitive naming. The folder names come directly from the classification codes in the filenames, eliminating the need for users to cross-reference against a table or manually rename classification directories.

Operation Steps: From Importing Files to Automatic Classification

Step One: Open "Classify files by filename" in File Organizing

After launching HeSoft Doc Batch Tool , select "File Organizing" in the left navigation bar. The right side will display function cards related to file organization, with the first function being "Classify files by filename". The requirement here is not to rename files or classify by extension, but to archive based on characters in the filename, so you should enter this function.

image-File name middle character classification,batch folder categorization,automatic file organization,file archiving by code,batch office file processing

After selecting this function, the software enters the task flow page. The interface guides the user through the operation step-by-step, starting with "Select records to process", then "Set processing options", "Set save location", and "Start processing". This flow helps users avoid missing any key settings.

Step Two: Add or Import Files from Folder for Processing

At the top of the task page, you can see buttons like "Add Files" and "Import Files from Folder". If the files are already gathered in a specific folder, importing from a folder is more efficient; if you only want to process some of them, you can use the add files method. Once imported, the files will appear in the list.

image-File name middle character classification,batch folder categorization,automatic file organization,file archiving by code,batch office file processing

The list displays file name, path, extension, creation date, modification date, and other information. It is recommended to check three key points here: first, whether the file count is correct; second, whether all filenames follow the same naming convention; third, whether any unnecessary files were imported by mistake. The screenshot shows a record count of 20, with filenames including 128LON75957.txt, 200LON66460.txt, 213TYO11946.txt, etc., indicating that the files for classification have been successfully imported.

After confirming everything is correct, click "Next" at the bottom of the page to proceed to classification rule settings. Do not rush to process; the accuracy of the rule settings directly impacts the classification results.

Step Three: Select Custom Position Range in Classification Method

After entering the "Set Processing Options" page, you can see multiple classification method options. For this example, the classification basis is not the first character of the filename, nor the first number or first English letter, but a three-letter code fixed in the middle of the filename. Therefore, you should select "Classify by characters in a custom position range".

image-File name middle character classification,batch folder categorization,automatic file organization,file archiving by code,batch office file processing

The purpose of this option is to tell the software: do not try to guess the classification characters, but extract characters according to the position range specified by the user. For office materials with clear file naming rules, this method is the most controllable and most likely to yield accurate results.

Step Four: Set the Range to 4:6

Fill in "4:6" in the "Range" input box. This means starting from the 4th character and ending at the 6th character, using this segment as the classification basis. Taking "200LON66460.txt" as an example, the 1st to 3rd characters of the filename body are 200, and the 4th to 6th characters are LON, so this file will go into the LON folder. Taking "307TYO91489.txt" as an example, the 4th to 6th characters are TYO, so it will go into the TYO folder.

When filling in the range, it's recommended to first verify using a few typical filenames. You can write out the filename and count character by character: 1, 2, 8 are the 1st, 2nd, and 3rd characters respectively; L, O, N are the 4th, 5th, and 6th characters respectively. Confirm this is correct before batch processing to avoid incorrect range settings leading to abnormal folder names.

Step Five: Choose Case Handling Based on Filename Situation

At the bottom of the page, there is a "Letter Case Conversion" setting. In the example, "Default" is kept because all codes are already in uppercase. If your files contain a mix of "lon", "LON", "Lon", and you want them all to go into the same folder, you can consider choosing to uniformly convert to uppercase or lowercase here. This can reduce the situation where multiple similar folders are generated due to different capitalizations.

If the filenames are already standardized, keeping the default is more appropriate, as it preserves the display of the original classification characters to the greatest extent.

Step Six: Set Output Location and Start Batch Organization

After completing the rule settings, continue to click "Next" and set the save location according to the interface prompts. It is recommended not to output directly into a cluttered directory, but to choose a new folder that is easy to inspect. This way, after processing, you can see at a glance which classification directories the software generated, and it's convenient to check the original files to confirm the results.

After the save location is set, proceed to "Start Processing". The software will read each filename one by one, extract the 4th to 6th characters, and then create or use the corresponding folder based on the extraction result, sorting the files into them. Upon completion, you will get directories like LON, NYC, PAR, SYD, TYO.

Common Questions and Precautions

Must the classification code be in English?

Not necessarily. The screenshot example uses English codes, but as long as the character position in the filename is fixed, it can also be numbers, Chinese characters, or combinations of letters and numbers. The key is not the character type, but whether they appear within a uniform range.

What if some files do not conform to the naming convention?

It is recommended to first screen for non-conforming files in the file list after import. Files with obviously different names can be removed first or processed separately. Batch classification relies on rules; the more uniform the rules, the more accurate the results.

What is the impact of writing the wrong range?

Writing the wrong range will cause the software to extract incorrect characters and generate wrong classification folders. For example, if it should extract LON, but you write 3:5, it might result in meaningless classifications like "8LO". Therefore, before batch processing, be sure to verify the range using typical filenames.

Can it be used for files of other formats?

Yes. This article uses txt files as a demonstration, but the concept is equally applicable to files like doc, docx, xls, xlsx, ppt, pptx, pdf, jpg, etc. As long as there is a code in a fixed position within the filename, you can organize them using this rule.

Summary: Replacing Manual Drag-and-Drop with Fixed Range Extraction Rules

Sorting a large number of files into folders based on the middle three characters of the filename is essentially a highly repetitive, rule-defined organization task. HeSoft Doc Batch Tool , as a batch office file processing software, helps users streamline this workflow: import files, choose to classify by characters in a custom position range, fill in 4:6, set the save location, and finally start processing.

Compared to manual classification, software batch processing is better suited for scenarios with a large number of files and fixed classification rules. It not only saves time but also reduces problems like mis-dragging, missed sorting, and creating duplicate folders. If you also have a batch of files named by number, city, project, or department code, it is recommended to first confirm the position of the classification characters, and then follow the steps in this article for automatic archiving.


Keyword:File name middle character classification , batch folder categorization , automatic file organization , file archiving by code , batch office file processing
Creation Time:2026-06-28 06:46: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!

Related Articles

Don't see the feature you want?

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