Many office files have classification information embedded within the filename, rather than in folders, such as a three-letter city code after a serial number. Using characters 4 to 6 as an example, this article explains how to use HeSoft Doc Batch Tool to batch-extract middle characters from filenames and automatically create classified folders like LON, NYC, PAR, SYD, TYO, helping users quickly organize their files.
In file management, you often encounter a situation where the filename itself contains classification information, but all files are still piled in the same directory. For example, "128LON75957.txt" and "284LON76499.txt" belong to LON; "307TYO91489.txt" and "615TYO56029.txt" belong to TYO; "378PAR56483.txt" belongs to PAR. The classification code is located in the middle of the filename, appearing very regular, but if you organize them manually, you still need to repeatedly check filenames and move files.
This article introduces a processing method more suitable for batch office work: using HeSoft Doc Batch Tool to classify files based on characters within a fixed range in the filename. The software can extract characters from the 4th to 6th position of the filename, automatically generate corresponding folders, and then group files with the same characters together. This way, whether they are txt texts, Word docs docx/doc, Excel spreadsheets xlsx/xls, PDFs, or images, as long as the naming convention is consistent, you can use the same method to complete batch archiving.
Applicable Scenario: Fixed Classification Fields in the Middle of Filenames
The core feature of this type of requirement is that the classification field appears at a fixed position in the filename, rather than at the beginning or end. The filename structure in the screenshots can be summarized as "three-digit number + three-letter code + five-digit number + extension". The three-letter code is the classification basis, such as LON, NYC, PAR, SYD, TYO.
If your files follow similar rules, they are very suitable for classification by custom position range. For example, characters 6 to 8 in a contract filename represent the region, characters 4 to 5 in a scan name represent the department, characters 10 to 12 in an image asset name represent the project, and certain digits in a log filename represent the device number. As long as these character positions are stable, you don't need to filter one by one; just let the software handle it in batch.
Compared to classifying by extension, classifying by characters in the middle of a filename is more refined. Extensions can only distinguish file types like txt, docx, pdf, jpg, while codes in filenames usually represent business meanings, making them more suitable for project archiving, regional archiving, customer data archiving, and batch data organization.
Effect Preview: Classification Info Hidden in Filenames Before Processing
In the file list before processing, all txt files are in the same directory. The red markings show the three-letter codes in the filenames, which are the classification fields we want to extract. Although you can see from their names that they belong to different categories, the file system does not yet have corresponding classification folders.

In this state, if a user wants to find files of a certain category, they usually can only search by keywords or sort manually. The problem is not obvious when the number of files is small, but as files continue to increase, the directory becomes more and more chaotic. Especially in multi-person collaboration scenarios, if everyone organizes differently, subsequent searching and handover will be affected.
Effect Preview: Similar Files Enter Same-Name Folders After Processing
After batch processing is complete, the software creates folders based on the extracted characters. In this example, five folders—LON, NYC, PAR, SYD, and TYO—are generated. Each folder name comes from characters 4 to 6 of the filename, and files with the same code are grouped into the same folder.

This result is very suitable for subsequent management. For instance, if you need to send LON-related files to the corresponding person, you can just compress the LON folder; if you need to count the number of SYD-related files, you can directly check the SYD folder. With a clear classification structure, file retrieval, packaging, backup, and sharing become more efficient.
Operation Steps: Batch Extract Middle Characters from Filenames for Classification
Step One: Open the File Organization Module
After launching HeSoft Doc Batch Tool , first select "File Organization" on the left. This software is positioned for batch office file processing and is suitable for completing repetitive tasks like file renaming, file organization, and document processing. This time, we need to classify many files by filename, so after entering "File Organization," select the function card "Classify files by filename."

Selecting the correct function is very important. "Classify files by filename" focuses on the character content in the filename, not the file extension or the file content itself. For cases like this example, where city codes, department codes, or project codes are in the middle of the filename, you should use this function.
Step Two: Import Files to be Organized
After entering the task, the software first asks you to select the records to process. At the top of the interface, you can see buttons like "Add Files," "Import Files from Folder," and "Clear." If all files to be organized are already gathered in one folder, it is recommended to click "Import Files from Folder" to load all files in the directory at once; if you only want to process some files, you can use "Add Files."

After the import is complete, the table will list the file name, path, extension, creation time, and modification time. In the screenshot, you can see the file path is D:\test\, and the number of records is 20. At this point, it is recommended to browse the list first to confirm whether the filenames all follow the same structure. If some files are not the target of this organization, you can remove them before starting the process to avoid generating unnecessary classification folders.
Step Three: Select "Classify by characters within a custom position range"
Click "Next" to enter the processing options setup. The classification method area provides multiple rules, including classify by first character, classify by first digit, classify by first English letter, classify by last few characters, classify by first few characters, and classify by custom regular expression, etc. The classification code in this example is in the middle of the filename, so you need to select "Classify by characters within a custom position range."

After selecting, fill in "4:6" in the "Range" field. This setting tells the software: start taking characters from the 4th position of the filename up to the 6th position, and use the obtained content as the folder name. Taking "200LON66460.txt" as an example, characters 4 to 6 are LON, so it will go into the LON folder; taking "943PAR93548.txt" as an example, characters 4 to 6 are PAR, so it will go into the PAR folder.
If the classification field in your filename is not from the 4th to 6th position, you need to modify the range according to the actual situation. For example, if the classification field is from the 2nd to 4th position, fill in "2:4"; if it's from the 8th to 10th, fill in "8:10". Don't mechanically apply the numbers from the example; the key is to first clarify the position of the classification field in the filename.
Step Four: Keep Case Settings and Continue to Next Step
In the screenshot, "Letter case conversion" is set to "Default." When the codes in the filenames are already uniformly uppercase, keeping the default is fine. This way, the generated folders will retain the original code form, such as LON, NYC, PAR. If there is mixed case in actual filenames, the user can decide whether conversion is needed based on organization standards, but no additional adjustment is needed in this example.
After completing the classification method and range settings, click "Next" at the bottom. The software process bar shows that "Set Save Location" and "Start Processing" follow. It is recommended to set the output location to a new folder for easy checking of the final result and to protect the original file directory structure.
Step Five: Set Save Location and Execute Batch Processing
After entering the save location step, choose the location where the processing results are to be stored. After confirming everything is correct, proceed to start processing. The software will read the file list entry by entry, determine the classification based on characters 4 to 6 of the filename, and automatically create the corresponding folders. Ultimately, files with the same code are placed in the same folder, forming a clear archiving structure.
The entire process does not require the user to manually create the LON, NYC, PAR, SYD, TYO folders, nor to drag and drop files one by one. For the test directory with 20 records, it can be completed almost instantly; for a larger volume of files, the efficiency advantage of batch processing will be even more apparent.
Frequently Asked Questions or Notes
1. Does the classification field include the extension?
Usually, when setting the range, you focus on characters in the file's main name. The "4:6" in the example extracts the filename characters LON, TYO, etc., before the txt extension, not the extension txt itself. When setting, you should use the main filename as a reference, avoiding counting the dot or extension as part of the classification field.
2. What if there are Chinese characters in the filename?
If Chinese characters are also at fixed positions, theoretically they can also serve as classification criteria. For example, if characters 4 to 5 in a filename are "财务" (Finance) or "人事" (HR), you can classify by the corresponding range. However, note that the naming length and character positions must be consistent across different files, otherwise the classification result may be inaccurate.
3. Can files with different extensions be organized at the same time?
From the operational logic, the software imports file records, and the table displays the extension. As long as the filename rules are consistent for files with different extensions, they can also be classified by characters at the same position. For example, if the same batch of project materials includes docx, xlsx, and pdf, and characters 4 to 6 are all project codes, they can be archived by project code.
4. Should I backup before processing?
For important materials, it is recommended to backup first or output the results to a new directory. The advantage of batch operations is speed, but it also means that an incorrect rule will quickly affect a large number of files. Using a small sample to test if "4:6" is correct first is a more prudent office habit.
Summary: Replace Manual Judgment with Rules to Make File Organization More Stable
When a fixed classification code is in the middle of a filename, the most effective way to organize is not to manually move them one by one, but to convert the code position into a batch processing rule. HeSoft Doc Batch Tool , through the "Classify files by filename" function, can extract characters based on a custom range, automatically generate classification folders, and archive the files.
If your office files, like the example, have classification information located at the 4th to 6th position of the filename, you can directly refer to this article and use "4:6" for processing. For a large number of txt, doc, docx, xls, xlsx, pdf, and other files, this method can significantly reduce repetitive labor, lower the probability of misclassification, and transform file management from a chaotic directory into a clear structure.