If the classification information for a batch of files is embedded in the middle of the file names—for example, positions 4 through 6 represent a city code or project code—manual sorting can be very tedious. This article explains how to use HeSoft Doc Batch Tool , select "Classify Files by File Name", import the files, set "Classify by Characters in Custom Position Range", enter the range as 4:6, and then batch-organize the files into corresponding folders such as LON, NYC, PAR, SYD, TYO, etc.
Many office files are not named arbitrarily but generated according to certain rules. For example, system-exported logs, business transactions, order data, project attachments, and client files often contain numbers, regions, departments, dates, or serial numbers in their names. The problem is that after these files are exported, they often pile up in the same folder. When users want to classify them by a specific field, they need to check the file names one by one and move them manually.
This article uses a batch of txt files as an example to demonstrate how to use characters at a fixed position in the middle of file names as classification criteria, automatically generate classification folders, and complete archiving. The file name format in the screenshots is similar to "128LON75957.txt", "213TYO11946.txt", "230SYD60610.txt", where the 4th to 6th characters are LON, TYO, SYD, etc. Our goal is to put files with the same character segment into the same folder, achieving batch classification of files with the same characters in the middle of their names.
The software used throughout the process is HeSoft Doc Batch Tool . It belongs to the category of office file batch processing software. Its core value lies in turning file organization, file name processing, and document processing operations that originally required manual repetitive effort into batch-executable processes. The following discussion covers applicable scenarios, effects before and after processing, specific steps, and considerations.
Applicable Scenarios: A Specific Segment of Characters in the File Name Represents Classification Information
Classifying by a specified position in the file name is most suitable for files with "uniform naming rules." For example, the first few characters might be a random number, the middle ones a classification code, and the last few a serial number. As long as the classification information is consistently positioned in each file name, files can be batch classified by specifying a character range.
The following scenarios are typical:
- City or site data: File names contain city codes such as LON, NYC, PAR, SYD, TYO;
- Departmental archiving: File names contain department abbreviations at a fixed position, such as FIN, HRD, MKT;
- Project file organization: The middle several characters of the file name represent a project code or phase;
- Batch download data organization: Attachment file names exported by platforms contain fixed fields;
- Multi-format office document organization: Including txt text, Word documents (doc and docx), Excel spreadsheets (xls and xlsx), PDF files, image materials, etc. As long as the naming rules are consistent, they can be classified by name rules.
The key to this requirement is not the file content, but the file name itself. Compared to opening each file to view its content, batch organizing directly based on file names is faster and more suitable for scenarios with a large number of files.
Effect Preview: All Files Mixed Together Before Processing
Before processing, multiple txt files are mixed in the folder. Although the file names contain classification characters like LON, TYO, SYD, PAR, they are not saved in categorized subfolders. If users want to find a specific category, they must look through the file list individually.

The red annotations in the screenshot highlight the classification characters in the middle of the file names. For example, "LON" in "128LON75957.txt", "TYO" in "213TYO11946.txt", "SYD" in "230SYD60610.txt". These characters are all located from the 4th to the 6th position of the file name and serve as the core basis for this batch classification.
If done manually, one would need to create folders for LON, TYO, SYD, etc., then filter or find the corresponding files, and finally drag them into the folders one by one. The more files there are, the more obvious the repetitive labor becomes; if file names are similar, it is also easy to drag them into the wrong place.
Effect Preview: Multiple Folders Generated Based on Middle Characters After Processing
After batch processing is complete, multiple classified folders appear in the output directory. The screenshot shows that folders like LON, NYC, PAR, SYD, TYO have been generated. Each folder name comes from the characters at the 4th to 6th position of the file name.

The processed directory structure is more suitable for office archiving: files with the same city code or project code are stored together, making subsequent searching, compression, sending, and backup more convenient. If further processing is needed for a certain type of file later, such as batch renaming, batch format conversion, or batch copying to other directories, it can also be done directly targeting the corresponding folder.
Operation Steps: Batch Classify by Characters from the 4th to 6th Position of the File Name
Step 1: Open the File Organization Function and Enter the File Name Classification Tool
After starting HeSoft Doc Batch Tool , click "File Organization" in the left navigation bar. Function cards related to file organization will be displayed on the right, with the first function being "Classify files by file name". This function is used to classify files based on characters, numbers, letters, or a custom range in the file name.

"Classify files by file name" is selected here because the classification basis for this requirement comes from the file name, not the extension, file size, or modification time. Other office processing categories can also be seen in the software interface, such as Word tools, Excel tools, PowerPoint tools, PDF tools, text tools, picture tools, etc., but this article only needs the file name classification capability under "File Organization".
After clicking this function card, the wizard page is entered. The wizard is divided into multiple steps, completing the selection of records, setting processing options, setting the save location, and starting the process in sequence. Following the steps reduces the chance of missing key settings.
Step 2: Import the Files to be Classified and Confirm the File List
After entering the function page, the first thing is "Select the records to be processed". The upper right corner of the page provides two main entry points: "Add Files" and "Import Files from Folder". If the files are concentrated in one directory, it is recommended to use "Import Files from Folder" to import all files from the entire folder at once; if only a few specific files need processing, you can click "Add Files".

After importing, the files will be displayed in a table. The table lists the sequence number, name, path, extension, creation time, modification time, and actions. The screenshot shows a total of 20 imported records, all with the txt extension, located in the D:\test directory. The main purpose of this page is to verify the processing objects and avoid classifying irrelevant files together.
Before formally proceeding to the next step, it is recommended to check three points: first, whether the number of files matches expectations; second, whether all file names follow the same rules; third, whether there are any files that should not be processed. If there are errors, you can remove single records through the actions on the right, or click "Clear" and re-import.
After confirming everything is correct, click "Next" at the bottom of the page to enter the classification method settings.
Step 3: Select the Custom Position Range Classification Method
After entering "Set Processing Options", the top of the page indicates that you are currently in Step 2. The most important setting here is "Classification Method". The interface lists various methods for classifying by file name, including classify by the first character, by the first number, by the first English letter, by the first English letter or Chinese character, by the first few characters, and by custom regular expression.
Since this example requires taking characters from a fixed position in the middle of the file name, rather than the first character or starting characters, "Classify by characters within a custom position range" needs to be selected. In the screenshot, this option is already selected.

After selecting this method, a "Range" input area appears below. The screenshot shows the range filled in as "4:6", indicating that characters between the 4th and 6th positions of the file name are taken as the classification name. This setting corresponds exactly to the pre-processing file names:
- "128LON75957.txt" takes the 4th to 6th characters, resulting in LON;
- "200LON66460.txt" takes the 4th to 6th characters, resulting in LON;
- "213TYO11946.txt" takes the 4th to 6th characters, resulting in TYO;
- "230SYD60610.txt" takes the 4th to 6th characters, resulting in SYD;
- "943PAR93548.txt" takes the 4th to 6th characters, resulting in PAR.
In other words, the software uses the extracted characters as the folder classification name. Files with the same characters will be grouped into one category, while files with different characters will go into different classification folders.
Step 4: Confirm the Letter Case Processing Rule
Below the "Range" setting, there is also a "Letter case conversion" option. The screenshot shows three options: "Default", "Convert to uppercase letters", "Convert to lowercase letters". The current selection is "Default".
If the case of the classification characters in the file names is completely uniform, for example, all in the form of LON, NYC, PAR, keeping the default is fine. If there is mixed case usage in the actual files, for example, the same type of file has "LON", "lon", "Lon", to avoid generating multiple different folders, you can choose to uniformly convert to uppercase or lowercase. This helps keep the classification directory tidy.
After completing the settings, click "Next". At this point, the classification rule is determined: classify by a custom position range in the file name, the range is 4:6, and case is kept as default.
Step 5: Set the Save Location and Execute Start Processing
Next, enter "Set Save Location". This step is used to specify which directory to save the sorted files to. For easy result checking, it is recommended to select a clear output location, such as creating a new folder specifically for saving the classification results. This way, even if you need to compare with the original files after processing, there will be no confusion.
After proceeding to the next step, enter "Start Processing". Before execution, you can review the previous settings: whether the imported files are correct, whether the classification range is 4:6, and whether the save location meets expectations. After confirming, start processing. The software will classify each file based on the characters from the 4th to 6th positions of its name and generate corresponding folders.
After processing is complete, open the save directory to see the classified folders LON, NYC, PAR, SYD, TYO, etc. At this point, the files have been automatically grouped according to the characters in the middle of their file names, achieving the goal of batch organization.
Common Problems and Considerations
1. How to determine which range should be filled in?
You can count the positions starting from the left of the file name. Taking "128LON75957.txt" as an example, 1 is the 1st position, 2 is the 2nd, 8 is the 3rd, L is the 4th, O is the 5th, N is the 6th, so to get LON, fill in "4:6". If your classification character position is different, adjust it according to the actual position.
2. What if the length of the characters in the middle of the file name is not fixed?
If some files have classification characters that are 3 characters long, while others are 4 characters, and the positions are inconsistent, then fixed-range classification may not be suitable. In this case, you can first standardize the file names, or choose a more suitable method based on other classification methods provided in the interface, such as classifying by the first few characters or by a custom regular expression.
3. Why did multiple folders with different cases appear after processing?
This is usually because the case of the classification characters in the file names is not uniform. For example, LON and lon might be treated as different text in folder names. To avoid this situation, you can choose "Convert to uppercase letters" or "Convert to lowercase letters" in the "Letter case conversion" option.
4. Is this method only applicable to txt files?
It is not only applicable to txt files. The examples in this article's screenshots are txt files, but the "classify by file name" logic applies to many office file organization scenarios. As long as the files can be imported and the file names follow the rules, it can be used for organizing doc, docx, xls, xlsx, ppt, pptx, pdf, and other common files. The actual processing scope depends on the software's support.
5. Is a backup needed before processing?
For important data, it is recommended to keep a backup of the original files first, or output the classification results to a new save location. This way, even if the range setting is inaccurate, you can readjust the rules and process again, avoiding impacts on the original file management.
Summary: Leave the Rules to the Software, Let Files be Auto-Categorized
When a certain number of characters in the middle of a file name represent classification information, the most effective way to organize is not manual, piecemeal movement, but having office software batch process them according to rules. Through the "Classify files by file name" function of HeSoft Doc Batch Tool , you can first import files, then choose "Classify by characters within a custom position range", set the range to "4:6", and finally specify the save location and start processing.
After processing, files will be automatically grouped according to the middle characters like LON, NYC, PAR, SYD, TYO. The directory structure is clear, and searching and archiving are more convenient. For users who frequently process large amounts of office files like txt, docx, xlsx, pdf, this batch classification method can significantly reduce repetitive labor and lower the risk of manual organization errors. It is recommended that when encountering similar file organization needs, you first observe the file naming pattern and then use the specified position character classification function to quickly complete the categorization.