How to Batch Classify Files into Folders by Specifying Character Ranges in Filenames


TranslationEnglishFrançaisDeutschEspañol日本語한국어Update Time2026-06-29 06:53:30

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 the naming of a large number of files includes fixed-position numbers, city codes, department codes, or project identifiers, manually creating folders and moving files one by one is very time-consuming. This article uses characters 4 to 6 in the file name as the classification basis to demonstrate how to use HeSoft Doc Batch Tool to automatically categorize multiple txt files into corresponding folders based on characters such as LON, NYC, PAR, SYD, and TYO, making it suitable for organizing batches of files like text documents, Word, Excel, and PDFs.

In daily office work, many files are not named arbitrarily but follow certain fixed rules. For example, file names may consist of numeric codes, city codes, client abbreviations, dates, and serial numbers: 128LON75957.txt, 200LON66460.txt, 213TYO11946.txt, 230SYD60610.txt. To a human, these file names might look like long strings of characters; but for batch processing tools, as long as a certain segment of characters has a pattern, it can be used as a classification basis.

The problem this article aims to solve is: when many files have classification characters at fixed positions within their names, how to batch organize these files automatically according to those character ranges. For instance, in the screenshot, the 4th to 6th characters of the file names are LON, TYO, SYD, PAR, NYC, etc. We want the software to automatically create or use corresponding category folders and organize similar files into them, avoiding manual filtering, copying, and moving one by one.

Below, we will use the operation interface of HeSoft Doc Batch Tool to demonstrate how to perform this file classification operation based on specified character ranges in file names using office software. This method is not only applicable to txt text files but also to doc, docx, xls, xlsx, ppt, pptx, pdf, images, and other files with uniform naming rules for file organization tasks.

Applicable Scenarios: Which Files Are Suitable for Classification by Fixed Character Range in File Names

Classifying files by a fixed range of characters in their names is suitable for scenarios where file naming has a unified structure. Simply put, as long as a batch of files contains characters with the same meaning at the same positions, they can be quickly organized using this method.

For example, in the file name 128LON75957.txt, the first 3 digits 128 might be a code, the 4th to 6th characters LON might represent a city or site, and the following 75957 might be a serial number. Similarly, in 213TYO11946.txt, the 4th to 6th characters TYO represent another category. At this point, if you want to put all LON files into a LON folder, all TYO files into a TYO folder, and all SYD files into a SYD folder, manual operation would be very tedious, making batch processing highly suitable.

Common applicable scenarios include:

1. Classification by city codes, such as LON, NYC, PAR, SYD, TYO, etc.;

2. Classification by department codes, such as fixed fields like HR, FIN, MKT, OPS;

3. Classification by project code, such as the 5th to 8th characters in the file name representing the project number;

4. Classification by client abbreviation, such as client codes included in contracts, invoices, and quotation files;

5. Classification by document type, such as identifiers like DOC, IMG, PDF in fixed positions of the file name;

6. Classification by batch number, such as data files exported in the same batch needing to be archived by batch.

The core of this organization method is not the file extension, but the pattern within the file name itself. Therefore, besides txt files, Word documents doc, docx, Excel spreadsheets xls, xlsx, PowerPoint files ppt, pptx, PDF files, image files, etc., can all be batch classified using the same approach, as long as they contain classification characters within a fixed range in their file names.

Effect Preview: Files Mixed in the Same Directory Before Processing, Automatically Sorted by Character After

First, look at the file state before processing. In the screenshot, you can see that all txt files are located in the same folder, with different three-letter English characters in the middle of their file names, such as LON, TYO, SYD, PAR, NYC. The positions highlighted in red emphasize the classification fields in the file names, which are the character ranges to be extracted for this batch organization.

image-Classify files by file name,batch organize files,classify by specified characters in file names,batch move files to folders,classify txt files

If there are only a dozen files, manual operation might still be manageable; but if there are hundreds or thousands of files, you would need to constantly check file names, determine classifications, create new folders, and drag files, which is both time-consuming and prone to misplacing files. Especially when dealing with client materials, experimental data, logistics documents, or project documents, once a classification error occurs, subsequent searching and delivery will be affected.

After processing is complete, the originally jumbled files are organized into multiple folders based on the specified characters in their file names. The screenshot shows that folders like LON, NYC, PAR, SYD, TYO have been generated, indicating that the software has completed grouping and categorizing based on the 4th to 6th characters of the file names.

image-Classify files by file name,batch organize files,classify by specified characters in file names,batch move files to folders,classify txt files

This result is very intuitive: whatever the classification character is, the file goes into the folder with that name. For subsequent viewing, you just need to open the corresponding folder to find similar files, eliminating the need to search repeatedly through a large number of files.

Operation Steps: Using HeSoft Doc Batch Tool to Classify Files by Specified Character Range

Below is a description of the complete operation process, explained in the order of the screenshots. The software used in this article is HeSoft Doc Batch Tool , which is a batch processing software tailored for office scenarios. Its core value is to offload repetitive tasks like file organization, file naming, and folder processing to the software, thereby reducing manual operation time.

Step 1: Enter the File Organization Function and Select to Classify Files by File Name

After opening HeSoft Doc Batch Tool , find the file organization related entry in the left-hand function navigation. In the screenshot, "File Organization" is selected on the left, and the function card "Classify Files by File Name" can be seen on the right. Pointing the mouse at this function indicates that this is the batch classification tool based on file names to be used this time.

image-Classify files by file name,batch organize files,classify by specified characters in file names,batch move files to folders,classify txt files

The purpose of this step is to enter the functional module suitable for the current task. Since we are not modifying file names or classifying by extension, but extracting a segment of characters from the file name as the classification basis, we should choose "Classify Files by File Name".

The expected result is to enter a step-by-step processing interface, where the software guides us through file selection, processing option settings, save location setup, and starting the process sequentially.

Step 2: Add the Files to be Classified and Confirm the Records to be Processed

After entering the "Classify Files by File Name" interface, you first arrive at Step 1, "Select records to be processed". In the upper right corner of the interface, you can see buttons like "Add Files", "Import Files from Folder", "Clear", "More", etc. For a small number of files, you can use "Add Files"; if the files are all concentrated in a specific directory, "Import Files from Folder" is more suitable.

image-Classify files by file name,batch organize files,classify by specified characters in file names,batch move files to folders,classify txt files

The table in the screenshot displays the imported file records, including information such as sequence number, name, path, extension, creation time, and modification time. In the example, there are 20 records, with the file extension txt, and the path is located under the test directory on the D drive. Through this list, you can confirm before formal processing whether the files are fully imported and whether there are any files that should not be processed.

The purpose of this step is to hand over the files needing batch classification to the software and verify them in the list. The expected result is that all target files appear in the record table with correct file names and paths displayed. If you find files imported by mistake, you can remove them via the delete operation in the list; if the imported quantity is incorrect, you can re-add or clear and re-import.

In batch processing scenarios, checking before importing is very important. Since the software will automatically organize files based on subsequent settings, confirming the file list in advance can reduce the risk of misoperation.

Step 3: Select Classification by Characters within a Custom Position Range

After confirming the file list, click "Next" at the bottom to enter Step 2, "Set Processing Options". In the screenshot, multiple classification method options can be seen, including classification by the first character, by the first digit, by the first English letter, by the first Chinese character, by the first English letter or Chinese character, by the first few characters, by the last few characters, by characters within a custom position range, and by a custom regular expression, etc.

image-Classify files by file name,batch organize files,classify by specified characters in file names,batch move files to folders,classify txt files

The file name structure in this example is the first three digits plus a three-letter city code plus a serial number, such as 128LON75957.txt. Therefore, the classification field is neither at the beginning nor at the end of the file name, but in the fixed 4th to 6th positions. At this point, "Classify by characters within a custom position range" should be selected.

In the "Range" input box, the example in the screenshot is filled with 4:6, indicating the extraction of the 4th to 6th characters from the file name as the category name. 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 categorized into the LON category; for 213TYO11946.txt, the 4th to 6th characters are TYO, so it will be categorized into the TYO category.

The purpose of this step is to tell the software from which position in the file name to extract the classification basis. The expected result is that the software identifies different classification characters based on the 4:6 range and creates corresponding folders after processing.

Step 4: Handle Letter Case as Needed

Below the same settings interface, you can also see the "Letter Case Conversion" area, which includes options like "Default", "Convert to Uppercase", and "Convert to Lowercase". In the screenshot, "Default" is selected.

If the classification characters in the original file names are consistently cased, for example, all are LON, NYC, PAR, keeping the default setting is fine. If the file name sources are not uniform, with mixed uses of lon, Lon, LON, you can uniformly convert to uppercase or lowercase based on actual needs to prevent the same category from being split into multiple folders. It should be noted that whether to convert should be decided according to internal enterprise naming conventions; this article's example keeps the default setting, resulting in final folder names of LON, NYC, PAR, SYD, TYO.

The purpose of this step is to ensure consistency in category names. The expected result is that classification characters with the same meaning are not scattered into different folders due to case differences.

Step 5: Set the Save Location and Start Processing

After completing the processing option settings, continue by clicking "Next". The interface flow shows that there are subsequently two more steps: "Set Save Location" and "Start Processing". Follow the wizard to further set the save location for the classified files, then proceed to the start processing step.

It is recommended here to choose a clear location based on your actual work habits, such as creating a new directory specifically for the output results, to avoid mixing them with the original files. For important files, it is advisable to keep a backup of the original files before formal batch processing, especially when dealing with contracts, financial materials, and project archiving files, where extra caution is warranted.

After processing is complete, open the save location, and you can see the category folders generated based on the specified character range in the file names. Consistent with the post-processing screenshot, this example ultimately formed folders like LON, NYC, PAR, SYD, TYO, with the files automatically organized into their corresponding directories.

Key Setting Explanation: Why the Range is Filled as 4:6

Many users, when using classification by specified character range for the first time, are most puzzled about how to fill in the range. The judgment method is actually very simple: count from the left side of the file name to find the start and end positions of the classification field.

Taking 128LON75957.txt as an example, if you disregard the extension txt and only look at the main file name 128LON75957:

The 1st character is 1, the 2nd is 2, the 3rd is 8, the 4th is L, the 5th is O, and the 6th is N. LON is exactly located in positions 4 to 6, so the range is filled as 4:6.

Next, look at 230SYD60610.txt, its main file name is 230SYD60610, and the 4th to 6th characters are SYD, so it will be categorized into the SYD folder. The 4th to 6th characters of 378PAR56483.txt are PAR, so it will be categorized into the PAR folder.

As long as the naming rules for this batch of files are consistent, the software can stably extract characters at the same positions to complete the classification. If file names have varying lengths but the classification field's position is fixed, this method can also be used; if the classification field's position is not fixed, other classification methods need to be considered, such as classification by starting characters, by ending characters, or by regular expression.

Common Questions and Precautions

1. Will the file extension affect the 4:6 range?

From the screenshot example, the range setting is used for character positions in the file name. In practice, you should refer to the file name display and rule description in the software interface. It is usually recommended to first select a small number of files for a test, confirm the extraction results meet expectations, and then batch process all files.

2. Can files with different extensions be classified together?

If the file name structure is consistent, different types of office files can usually be organized in the same batch, such as doc, docx, xls, xlsx, pdf, txt, etc. However, in practical work, for easier verification, you can also import and process them in batches by project or file type first.

3. What if some file names do not conform to the rule?

If some file names do not have sufficient length, or the 4th to 6th characters are not the expected classification characters, the processing result may not meet expectations. Therefore, after importing files, you should first check the names in the list, and if necessary, exclude abnormal files beforehand, or standardize file naming first.

4. Is a backup needed before classification?

A backup is recommended. While batch processing files can significantly improve efficiency, if the rule setting is incorrect, it may also lead to unsatisfactory organization results. For important materials, you can copy a test directory and confirm the rules are correct before processing the formal files.

5. Will folder names automatically come from the classification characters?

From the post-processing effect, the final generated or presented folder names are LON, NYC, PAR, SYD, TYO, consistent with the classification characters extracted from the file names. Therefore, the classification results in this example intuitively correspond to the 4th to 6th characters in the file names.

Summary: Use Batch Classification to Reduce Time Spent on Repetitive File Moving

When file names contain classification information at fixed positions, manual organization is not the most efficient method. Through the "Classify Files by File Name" function in HeSoft Doc Batch Tool , the repetitive processes of screening, creating folders, and moving files can be handed over to the software. In the example of this article, you just need to import files, select "Classify by characters within a custom position range", set the range to 4:6, then follow the wizard to continue setting the save location and start processing, and the txt files can be quickly categorized by characters like LON, NYC, PAR, SYD, TYO.

If you are dealing with a large number of similarly named text, Word, Excel, PDF, or other office files, it is recommended to first sample a few files to confirm the position of the classification characters, then use the batch classification function to complete the organization. This not only reduces repetitive labor but also makes file archiving clearer and more stable, making subsequent searching and delivery more efficient.


KeywordClassify files by file name , batch organize files , classify by specified characters in file names , batch move files to folders , classify txt files
Creation Time2026-06-29 06:53:15

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!