How to Batch Classify Files by Characters 4 to 6 in the File Name and Automatically Archive Them


TranslationEnglishFrançaisDeutschEspañol日本語한국어Update Time2026-06-29 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!

When a large number of filenames contain fixed-position codes, city codes, department abbreviations, or project identifiers, manually creating folders one by one and then moving files is very time-consuming. This article explains how to use HeSoft Doc Batch Tool to automatically categorize files such as txt files into corresponding folders based on the 4th to 6th characters of the filename, suitable for handling fixed-range character classification needs such as LON, NYC, PAR, SYD, TYO.

In daily office work, the naming rules for many files are not arbitrary. For example, the file names in the screenshot are "128LON75957.txt", "200LON66460.txt", "213TYO11946.txt", "230SYD60610.txt", etc. They have a number at the front, the 4th to 6th characters in the middle are city or category codes, followed by a serial number. For such files, if you want to sort them into different folders based on codes like "LON, NYC, PAR, SYD, TYO", manual operation usually requires first identifying the file name, then creating new folders, and finally dragging and moving them one by one. It is easy to make mistakes when the number of files is large.

The problem this article aims to solve is: batch sorting many files into groups based on characters within a fixed range in the file names. This example uses txt files, but the logic applies equally to other files with clear naming rules, such as doc, docx, xls, xlsx, pdf, jpg, etc. By using the file organizing capability of the office software " HeSoft Doc Batch Tool ", you can extract characters at a specified position in the file name as the category name, and automatically generate corresponding folders, thereby reducing repetitive work and improving file archiving efficiency.

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

Classification by fixed-range characters in file names is suitable for situations where the file name structure is relatively uniform. For example, in "128LON75957.txt", the 1st to 3rd characters are a numeric code, the 4th to 6th characters are the city code "LON", and from the 7th character onwards is another number. As long as all files follow a similar rule, you can set a character range to let the software automatically extract the content at a fixed position as the basis for classification.

Common scenarios include: organizing files by city code, such as LON, NYC, PAR, SYD, TYO; organizing files by department abbreviation, such as FIN, MKT, HRD; organizing files by project number, such as A01, B02, C03; batch archiving by customer code, warehouse code, batch code, or contract code. For large numbers of txt log files, Word documents docx/doc, Excel spreadsheets xlsx/xls, PDF materials, image assets, etc., this method can be used as long as the file name contains classification information at a fixed position.

The advantage of this method is that it does not require opening file contents or judging the category of each file individually. The software directly reads the file name and classifies it based on the range you set, making it suitable for finance, HR, sales, administration, operations, and data management roles handling hundreds or thousands of files.

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

Before processing, all files are placed together in the same folder. Although the file names already contain classification information, this information is just "hidden" in the names and does not form an actual folder structure. In the screenshot, you can see that the 4th to 6th characters of the file names include LON, TYO, SYD, PAR, NYC, etc., and the red markings also highlight these fixed-position characters.

image-Categorize files by name,batch organize files,sort by fixed characters,batch archive files,categorize txt files

If you only have a dozen files to process, manual sorting might be manageable; but if there are hundreds or thousands of files, obvious problems arise: time-consuming searches, easy misplacement when dragging, overlooking the creation of folders with the same name, and inconsistent classification rules. Especially when file names are highly similar, it is easy to mistake codes like "SYD" and "TYO" by visual inspection alone.

Effect Preview: After processing, category folders are automatically generated

After processing, the software automatically creates corresponding folders based on the 4th to 6th characters of the file names and moves the matching files into their respective directories. In the screenshot, you can see the result generated five folders: LON, NYC, PAR, SYD, and TYO. These folder names are exactly the characters extracted from the fixed range in the file names.

image-Categorize files by name,batch organize files,sort by fixed characters,batch archive files,categorize txt files

After organizing like this, finding files becomes more intuitive. For example, if you need to view all LON-related files, simply open the LON folder; if you need NYC-related files, go to the NYC folder. Work that originally required repetitive filtering, sorting, and dragging becomes a single batch process.

Operation Steps: Using HeSoft Doc Batch Tool to classify by file name range

Step 1: Enter the file organization function and select classification by file name

After opening HeSoft Doc Batch Tool , select "File Organization" from the left-side function navigation. This office software provides various batch processing capabilities; the current task is to organize file locations, so you need to enter the File Organization module. In the interface, you can see multiple function cards related to file organization, the first of which is "Classify files by file name".

image-Categorize files by name,batch organize files,sort by fixed characters,batch archive files,categorize txt files

After clicking "Classify files by file name", the software will enter the corresponding task flow. The purpose of this function is to generate a classification basis from a certain part of the file name and place the files into corresponding folders. For this requirement of classifying by fixed character positions, choosing this function is the most direct approach.

Step 2: Add files or import files from a folder

After entering the task page, the first step is "Select the records to be processed". At the top of the interface, there are two entry points: "Add Files" and "Import Files from Folder", and you can also see operations like "Clear". If the number of files is small, you can click "Add Files" to select them individually; if the files are all in the same directory, it is recommended to use "Import Files from Folder" to import the files from the directory into the list all at once.

image-Categorize files by name,batch organize files,sort by fixed characters,batch archive files,categorize txt files

After importing, the software will display information such as file sequence number, name, path, extension, creation time, and modification time in a table. In the screenshot, the number of records is 20, the extension is txt, and the path is located in the test directory on the D drive. At this point, you can first check if the file names conform to the rule, for example, whether they all have the structure of "three-digit number + three-letter classification code + subsequent serial number". If you find files that do not need processing, you can remove them through the operation items in the table to avoid incorrect classification.

Step 3: Set processing options, select custom position range

After confirming the file list is correct, click "Next" to enter "Set Processing Options". In the classification method, the software provides various rules for classifying by file name, such as by the first character, by the first number, by the first English letter, by the last few characters, or by the first few characters. Since this example needs to extract the city code from the 4th to 6th characters of the file name, you need to select "Classify by characters within a custom position range".

image-Categorize files by name,batch organize files,sort by fixed characters,batch archive files,categorize txt files

After selecting this option, enter "4:6" in the "Range" input box. This can be understood as starting from the 4th character of the file name and ending at the 6th character, extracting this segment as the classification name. Taking "128LON75957.txt" as an example, the 1st character is 1, the 2nd is 2, the 3rd is 8, and the 4th to 6th characters are LON, so this file will be classified into the LON folder; for "213TYO11946.txt", the 4th to 6th characters are TYO, so it will go into the TYO folder.

There is also a "Letter Case Conversion" option at the bottom of the interface; in the screenshot, "Default" is selected. If the case of the classification codes in your file names is already unified, for instance, all are LON, NYC, PAR, then keeping the default is fine. This preserves the classification characters in the original file names to the greatest extent, without changing the letterform of the classification folder names.

Step 4: Set save location and start processing

After completing the classification rule settings, continue by clicking "Next" to enter "Set Save Location". Although the screenshot does not show the specific save path page for this step, the progress bar indicates that the software executes in the order of "Select Records - Set Processing Options - Set Save Location - Start Processing". It is recommended to save the processing results to a new destination folder for comparing the structure before and after processing, and to avoid mixing with files in the original directory.

After setting the save location, go to "Start Processing" and execute the task. The software will batch read the characters from each file name based on the "4:6" range just set, automatically create folders like LON, NYC, PAR, SYD, TYO, and organize the corresponding files into them. After completion, you will get the categorized folder structure as shown in the previous effect image.

Frequently Asked Questions and Notes

1. What does the range "4:6" mean?

It means extracting the 4th to 6th characters from the file name as the classification basis. The range should be determined based on the actual file name structure. If your classification code is at the 5th to 7th position, you should set it to "5:7"; if it is at the 1st to 3rd, set it to "1:3". Before setting it, it's best to manually count the character positions for a few selected files.

2. Can file names with inconsistent lengths be processed?

If the position of the classification field is consistent, it usually does not affect the classification even if the subsequent serial numbers have different lengths. However, if some file names lack a prefix, causing the position of the classification characters to shift, it might lead to misclassification. Therefore, before batch processing, it is recommended to check if the naming rules are unified.

3. Can this approach be used for docx, doc, pdf, and image files?

The examples in the screenshots for this article are txt files, but the core basis for classification by file name is the "characters of the file name", not the file content. As long as the file name rules meet the requirements, Word documents docx/doc, Excel spreadsheets xlsx/xls, PDFs, images, compressed packages, etc., can all be batch-organized using the same approach.

4. Why is it recommended to test with a small number of files first?

When the number of files is very large, it is advisable to first copy a small subset of files for trial processing. After confirming that the classification folder names and file assignments are correct, perform the batch operation on the entire directory. This can avoid generating a large number of misclassification results due to incorrect range settings.

Summary: Turning fixed characters in file names into automatic classification rules

Batch classification by fixed-range characters in file names is essentially about handing over naming rules that originally required manual identification to office software for automatic execution. Through its "Classify files by file name" function, HeSoft Doc Batch Tool allows users to quickly organize a large number of files into corresponding folders simply by importing files, setting the character range, and choosing a save location.

If your file names also contain fixed-position city codes, department abbreviations, project numbers, or batch identifiers, you can try setting the range according to the method in this article, for example, "4:6". Compared to manually creating new folders and moving files one by one, batch processing is not only faster but also more stable, making it particularly suitable for office scenarios requiring the long-term organization of large amounts of data.


KeywordCategorize files by name , batch organize files , sort by fixed characters , batch archive files , categorize txt files
Creation Time2026-06-29 06:50:37

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!