How to batch classify files into folders by characters 4 to 6 of the file name


Translation:EnglishFrançaisDeutschEspañol日本語한국어,Update Time:2026-06-28 06:48: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!

When a large number of file names contain fixed-position numbers, city codes, department abbreviations, or project identifiers, manually creating new folders and moving files one by one is very time-consuming. This article uses the 4th to 6th characters in the file name as the classification basis, demonstrating how to use HeSoft Doc Batch Tool to batch categorize a large number of txt files into corresponding folders, such as automatically grouping by characters like LON, NYC, PAR, SYD, TYO, helping users quickly complete file organization and reduce repetitive work.

In daily office work, you often encounter a batch of files whose names look very similar, but where certain characters in the middle represent different categories. For example, order files, logistics records, inspection reports, city data, project materials, customer archives, etc., might have filenames in the format "128LON75957.txt", "200LON66460.txt", "213TYO11946.txt". In these names, the 4th to 6th characters "LON", "TYO", "SYD", "PAR", "NYC" represent the city or business category. If there are only a few files, manually dragging them is acceptable; but if there are dozens, hundreds, or even more files, checking filenames one by one, creating folders, and moving files is not only inefficient but also prone to miscategorization and mistakes.

The problem this article aims to solve is: How to batch-sort numerous files into groups based on characters within a fixed range in their filenames. Through the "Sort Files by Filename" feature in HeSoft Doc Batch Tool , the office software can automatically generate a classification basis based on characters at a specified position in the filename and organize the same type of files into corresponding folders. Below, combined with screenshots, it explains the effect before processing, the effect after processing, and the specific operating steps.

Applicable Scenarios: Which files are suitable for batch classification by fixed-position characters

Classifying files by characters within a fixed range in the filename is suitable for scenarios with relatively unified file naming rules. For example, the first 3 digits of a filename are a serial number, the 4th to 6th digits are a city code, and the rest is a serial number; or the first few digits are a date, the middle few are a department code, and the last part is a file number. As long as the key information needed for classification is at a fixed position in the filename, this method can be used to quickly complete batch archiving.

Common scenarios include:

  • Classification by city code: e.g., LON, NYC, PAR, SYD, TYO;
  • Classification by department abbreviation: e.g., HR, FIN, OPS, MKT, where a range can also be set if the position is fixed;
  • Classification by project number: certain digits in the filename represent the project group or project phase;
  • Classification by customer identifier: a fixed character segment in the filename represents a customer abbreviation or customer number;
  • Organizing by document type extension: although the screenshots in this article use txt files, similar rules are also commonly used for batch organization of office documents like doc, docx, xls, xlsx, ppt, pptx, pdf.

Compared to manual organization, the advantage of batch processing is that you only need to set the classification rule once, and the software will process all files uniformly according to that rule. For file organization tasks that are highly repetitive and have clear rules, this type of office software can significantly reduce the cost of manual operation.

Effect Preview: Before processing, files are mixed in the same directory

Before processing, all txt files are placed in the same folder. Although the filenames all contain classification characters, different categories are mixed together, requiring manual identification. For example, in the screenshot, you can see files like "128LON75957.txt", "200LON66460.txt", "213TYO11946.txt", "230SYD60610.txt", etc., where the positions marked in red are the classification characters in the filenames.

image-Classify files by filename,batch organize files,classify by specified characters,batch process files,txt file classification

From these filenames, it can be seen that the classification basis is neither the extension nor the file creation time, but a segment of characters at a fixed position in the filename. Taking "128LON75957.txt" as an example, if counting from left to right, the first 3 characters "128" are a serial number, and the 4th to 6th characters "LON" are the content to be used for this classification. Therefore, during the operation, you need to select "Classify by characters within a custom position range" and set the range to "4:6".

Effect Preview: After processing, corresponding classification folders are automatically generated

After processing is complete, the originally mixed files will be automatically categorized according to the 4th to 6th characters in their filenames. In the screenshot, you can see that the software has generated or organized folders such as LON, NYC, PAR, SYD, TYO, and files corresponding to different city codes have been placed into the corresponding folders.

image-Classify files by filename,batch organize files,classify by specified characters,batch process files,txt file classification

This organized result is very intuitive: in the future, to find files related to LON, you only need to go into the LON folder; to find files related to TYO, you only need to go into the TYO folder. For a large number of business files, batch classification by fixed characters in the filename can make the directory structure clearer and also facilitate subsequent backup, sharing, archiving, and secondary processing.

Operating Steps: Using HeSoft Doc Batch Tool to Sort Files by Specified Character Range

Step One: Enter "File Organization" and select "Sort Files by Filename"

After opening HeSoft Doc Batch Tool , select "File Organization" in the left function bar. In the function cards on the right, you can see the "Sort Files by Filename" feature. The purpose of this function is to automatically group files based on their filenames, which is suitable for the need described in this article to sort files by fixed characters in their names.

image-Classify files by filename,batch organize files,classify by specified characters,batch process files,txt file classification

In this interface, the software's left side also provides entry points for categories like Word Tools, Excel Tools, PowerPoint Tools, PDF Tools, Text Tools, Image Tools, indicating that it is a toolbox for batch processing office files. This article uses the file classification function under "File Organization", which doesn't require opening each file's content or manually copying and pasting files; it only needs to organize based on filename rules.

After clicking "Sort Files by Filename," you will enter the processing wizard for this function. The wizard-style process helps users complete steps in order – selecting files, setting rules, setting the save location, and starting processing – reducing the probability of errors in batch operations.

Step Two: Add the files to be processed or import files from a folder

After entering the "Sort Files by Filename" page, you first arrive at Step 1, "Select records to process". In the upper right corner of the interface, you can see buttons like "Add File", "Import Files from Folder", "Clear", and "More". For situations with a large number of files, you can usually use "Import Files from Folder" to import files from a specific directory into the list all at once; if you only want to process some files, you can also use "Add File".

image-Classify files by filename,batch organize files,classify by specified characters,batch process files,txt file classification

After importing, the table will list information such as the file's serial number, name, path, extension, creation time, and modification time. In the screenshot, you can see that the file paths are from the D drive test directory, the extension is txt, and the record count is 20. The purpose of this list is to allow the user to confirm before formal processing: whether the files are fully imported, whether the filenames meet expectations, and whether there are any files that should not be processed.

If you find that a certain file should not participate in the classification, you can remove that record through the delete operation on the right side of the table; if the import is wrong, you can also use "Clear" to reselect. After confirming the list is correct, click "Next" at the bottom to enter the classification rule settings.

Step Three: Select "Classify by characters within a custom position range"

In Step 2, "Set processing options", you need to specify which part of the filename the software should use for classification. The "Classification Method" in the interface provides multiple choices, such as classify by the first character, by the first number, by the first English letter, by the first few characters, by a custom regular expression, etc. The requirement of this article is to classify by characters within a fixed range in the filename, so you should select "Classify by characters within a custom position range".

image-Classify files by filename,batch organize files,classify by specified characters,batch process files,txt file classification

In the screenshot, "Classify by characters within a custom position range" is already selected, and "4:6" is filled in the "Range" input box. This means the software will read the 4th to 6th characters of the filename and use this segment as the classification name. For example:

  • 128LON75957.txt: The 4th to 6th characters are LON, so it is categorized under LON;
  • 213TYO11946.txt: The 4th to 6th characters are TYO, so it is categorized under TYO;
  • 230SYD60610.txt: The 4th to 6th characters are SYD, so it is categorized under SYD;
  • 378PAR56483.txt: The 4th to 6th characters are PAR, so it is categorized under PAR.

It is particularly important to note that the correctness of the range filled in directly determines the classification result. If the first 3 digits of the filename are a serial number, and the classification characters start from the 4th position and end at the 6th, fill in "4:6". If your filename rule is different, for example, if the classification characters are in the 5th to 8th position, you should fill in the corresponding range according to the actual situation.

Step Four: Set letter case conversion as needed

At the bottom of the same settings page, you can see the "Letter Case Conversion" option, which includes "Default", "Convert to Uppercase", and "Convert to Lowercase". In the screenshot, "Default" is selected, indicating that the original letter form in the filename is maintained.

If your filenames might contain inconsistencies in letter case, such as "lon", "LON", "Lon", classification might produce multiple folders that appear the same but have different names. In this case, you can choose to convert to uppercase or lowercase according to actual needs to keep the classification names uniform. In the screenshot of this article, the classification characters in the filenames are already uppercase, so keeping "Default" is fine.

Step Five: Set the save location and start batch processing

After completing the classification rule settings, click "Next" to enter Step 3, "Set save location". This step is used to determine where the classified files will be saved. It is generally recommended to choose a clear output directory to avoid confusion with the original files and to facilitate checking the results after processing is complete.

Continue clicking "Next" to enter Step 4, "Start processing". Before officially starting, you can reconfirm whether the number of imported files, the classification rule, and the save location are correct. After confirming there are no errors, execute the processing; the software will automatically create or use corresponding classification folders based on the 4th to 6th characters and categorize the files together.

After processing is complete, you can open the output directory to check the results. Under normal circumstances, you will see folders corresponding to the classification characters, such as LON, NYC, PAR, SYD, TYO. Each folder stores the corresponding files for that classification.

Common Questions and Considerations

1. What does "4:6" mean?

"4:6" means starting from the left side of the filename, take the 4th to the 6th characters as the classification basis. Taking "128LON75957.txt" as an example, the 1st to 3rd characters are 128, and the 4th to 6th characters are LON, so it will be classified by LON.

2. Will the extension, like txt, be included in the position calculation?

Judging from the screenshots and the purpose of the function, the classification rule mainly targets the content of the filename. When using it in practice, the preview in the software interface or the processing result should prevail. To avoid misjudgment, it is recommended to test with a small number of files first to confirm the range setting is correct before processing a large number of files.

3. What if the filenames have inconsistent lengths?

If some filenames are too short, or the classification characters are not in the same position, sorting by a fixed range may not yield the desired result. For such files, it is recommended to unify the naming rules first, or choose a more suitable classification method, such as sorting by the first few characters, by the first English letter, or by a regular expression.

4. Can this be used for office documents like docx, xlsx, pdf?

The examples in this article use txt files, but the concept of "classifying by filename" is not limited to txt. As long as the filename conforms to a rule, common Word documents (doc, docx), Excel spreadsheets (xls, xlsx), PDF files, image files, etc., can all be batch-organized based on fixed characters in the filename. The specific file types that can be processed are subject to the software's import and function support.

5. How to avoid classification errors?

It is recommended to check the file naming pattern before processing to confirm the position of the classification characters is consistent; after importing files, check if the names in the list are correct; after setting the range, test with a small number of samples first; after processing is complete, spot-check each classification folder. For important files, it is recommended to keep a backup of the original files first.

Summary: Replace manual dragging with batch classification to improve file organization efficiency

When a large number of files need to be sorted by characters within a fixed range in their filenames, manual organization is not only time-consuming but also highly error-prone. Using HeSoft Doc Batch Tool , you can use the "Sort Files by Filename" feature in "File Organization" to take a specified character segment, such as the 4th to 6th characters of the filename, as the classification basis, batch-generate folders like LON, NYC, PAR, SYD, TYO, and automatically group the corresponding files together.

This method is particularly suitable for office scenarios with unified naming rules, a large number of files, and the need for repetitive organization. Compared to manually judging and dragging files one by one, batch processing can shorten file archiving tasks that might otherwise take a long time to just a few steps of setup. It is recommended that when you encounter similar file organization tasks for txt, docx, xlsx, pdf, etc., you first observe the patterns in the filenames, and then use the fixed-position character classification function to complete automatic categorization.


Keyword:Classify files by filename , batch organize files , classify by specified characters , batch process files , txt file classification
Creation Time:2026-06-28 06:48:02

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!