Batch file classification by filename ending: automatically archive txt files with city codes into folders


Translation:EnglishFrançaisDeutschEspañol日本語한국어,Update Time:2026-07-20 06:39: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 files have fixed codes at the end of their filenames, such as city codes like LON, NYC, PAR, SYD, TYO, manually creating folders and copying or moving files one by one can be very time-consuming. This article uses HeSoft Doc Batch Tool as an example to explain how to batch archive txt and other files into corresponding folders by categorizing based on the last few characters of the filename, suitable for organizing reports, logs, orders, resource packages, and other file arrangements.

In daily office work, we often encounter a type of file: there are many files, and the filenames look like a string of numbers plus a fixed suffix, such as 10102271LON.txt, 10103956PAR.txt, 10179839NYC.txt. The preceding numbers might represent an order number, customer ID, serial number, or collection ID, while the characters at the end of the filename, like LON, PAR, NYC, SYD, TYO, are the actual identifiers used for categorization.

If you are only dealing with a dozen files, manually dragging them into different folders is acceptable; but when the number of files reaches dozens, hundreds, or even thousands, checking the end characters of each filename one by one, creating new folders individually, and moving files one at a time is not only inefficient but also prone to placing files in the wrong location. Especially for batch files like txt logs, csv data, doc or docx documents, xlsx spreadsheets, pdf materials, once the categorization rules are clear, it is more suitable to let office software handle it automatically.

The problem this article aims to solve is: how to batch-categorize many files based on the last few characters of their filenames. The example below uses the screenshot of HeSoft Doc Batch Tool to demonstrate how to automatically archive txt files whose last 3 characters are the same into a folder with the same name. For example, files ending in LON go into the LON folder, files ending in PAR go into the PAR folder, and files ending in NYC go into the NYC folder.

Applicable Scenarios: Which Files Are Suitable for Categorization by Filename End Characters

Categorization by filename end characters is suitable for scenarios where the filename itself already contains a category identifier. Common situations include: the first half of the filename is an ID, and the last few characters are a region, department, project, channel, month, or type code. For example, BJ, SH, GZ at the end of customer files represent cities; A01, B02 at the end of sales reports represent stores; PAR, LON, NYC at the end of order files represent sites or regions.

The core of this organization method is not identifying file content, but using the pattern in the filenames for batch archiving. As long as the last few characters of the filename before the extension are stable, the same set of rules can be used for batch processing. In the screenshot example, all files are txt files, and the name structure roughly consists of a numeric ID plus a city code, like 10102271LON.txt. The actual basis for categorization here is the last 3 characters, LON, before the .txt extension.

Besides txt files, similar rules can also apply to many types of office files, such as doc, docx, xls, xlsx, ppt, pptx, pdf, csv, jpg, png, and so on. As long as the category characters at the end of the filename follow a pattern, batch processing can be used to reduce repetitive work.

Effect Preview: Files Mixed in the Same Directory Before Processing

Before processing, all files are placed in the same folder. Although the filenames already contain identifiers like LON, PAR, SYD, NYC, TYO, they are still mixed together. Users need to visually identify the last few characters of the filename to determine which category each file belongs to.

image-Organize files by filename,batch organize files,classify by filename ending characters,classify txt files,batch archive files

As seen in the pre-processing screenshot, the three English characters at the end of the filenames are specifically highlighted. For example, the end category characters for 10102271LON.txt are LON, for 10103956PAR.txt are PAR, and for 10166063SYD.txt are SYD. This rule is very clear, making it suitable for a one-time organization using the batch categorization feature.

If done manually, you would roughly need to first create folders like LON, PAR, SYD, NYC, TYO, and then select and move files one by one. The more files there are, the higher the chance of error. After batch organization using office software, these repetitive actions can be completed automatically by the software.

Effect Preview: Category Folders Automatically Generated After Processing

After processing is complete, the originally intermingled files will be organized into categories based on the last 3 characters of the filename. The example shows that the system generated or organized folders like LON, NYC, PAR, SYD, TYO, with each type of file placed in the corresponding directory.

image-Organize files by filename,batch organize files,classify by filename ending characters,classify txt files,batch archive files

This result is very intuitive: to view London-related files, open the LON folder; to view Paris-related files, open the PAR folder; to view New York-related files, open the NYC folder. For subsequent searching, packaging, uploading, backing up, or distribution, this is more efficient than having all files piled in a single directory.

Operation Steps: Using HeSoft Doc Batch Tool to Categorize Files by End Characters

The complete workflow is explained below in the order of the operation screenshots. HeSoft Doc Batch Tool is a batch processing software designed for office scenarios, with an interface containing categories like File Organizing, Word Tools, Excel Tools, PowerPoint Tools, PDF Tools, Text Tools, Image Tools, etc. This article uses the file categorization by filename capability within File Organizing.

Step One: Enter File Organizing, Select Categorize Files by Filename

After opening HeSoft Doc Batch Tool , select File Organizing in the left function area. After entering the File Organizing page, you can see multiple function cards related to batch file processing, such as Categorize files by filename, Categorize files by extension, Batch create new folders based on existing ones, etc.

The goal this time is archiving by filename end characters, so the first function, Categorize files by filename, needs to be selected. This function's purpose is to batch-sort files into different folders based on specified character rules in the filenames.

image-Organize files by filename,batch organize files,classify by filename ending characters,classify txt files,batch archive files

After selecting this function, the software enters a wizard-style operation flow. The top of the wizard usually displays the current steps, such as Select records to process, Set processing options, Set save location, Start processing. This flow is suitable for batch tasks because users can first confirm the file list, then set categorization rules, and finally execute uniformly, avoiding missteps from the start.

Step Two: Add or Import Files Needed for Categorization

After entering the Categorize files by filename page, the first step is to select the records to process. On the top right of the interface, you can see operation buttons like Add File, Import files from folder, Clear, More, etc. For a small number of files, you can use Add File; to organize a batch of files in a directory, the more common approach is to Import files from folder.

After importing, files will be displayed in a list. The list contains information such as serial number, name, path, extension, creation time, modification time, and operations. Through this list, users can confirm whether the software has read the correct files and if the file count meets expectations.

image-Organize files by filename,batch organize files,classify by filename ending characters,classify txt files,batch archive files

The screenshot shows that files have been imported into the task list, with a record count of 20. The file paths are in the same test directory, and the extension is txt. The Name column shows the full filenames, such as 10102271LON.txt, 10103956PAR.txt, 10109610PAR.txt, etc. Do not rush to process at this point; the key is to check if the filename rules are consistent: the category identifiers for these files are all located in the last 3 characters before the extension.

If some files are found unnecessary for organization, you can remove the corresponding records through the operation column in the list; if the wrong directory was imported, you can also use Clear and re-import. Checking the list before batch processing is an important step to reduce categorization errors.

Step Three: Set the Categorization Method to By the Last Few Characters

After confirming the file list is correct, click Next at the bottom of the page to enter Set processing options. On this page, the software provides various categorization methods, including By first character, By first number, By first English letter, By the first few characters, By the last few characters, By characters within a custom position range, By custom regular expression, etc.

The filename rule in this example is: the last 3 characters before the extension represent the category. Therefore, you need to select By the last few characters and enter 3 in the number input field. This way, the software will extract the last 3 characters from each filename as the basis for categorization.

image-Organize files by filename,batch organize files,classify by filename ending characters,classify txt files,batch archive files

The screenshot shows By the last few characters is selected, with the number set to 3. For 10102271LON.txt, the software will take LON as the category name; for 10103956PAR.txt, it will take PAR; for 10179839NYC.txt, it will take NYC. Ultimately, these category names will correspond to different folders.

On the same page, below, you can also see letter case conversion options, including Default, Convert to uppercase, Convert to lowercase. In the example, keeping Default is fine because the codes like LON, PAR in the filenames are already consistently cased. If the actual files contain both lon, LON, Lon, etc., deciding whether to unify the case depends on your organization needs to avoid splitting the same type of file into multiple directories due to case differences.

Step Four: Proceed to the Next Step, Set the Save Location, and Start Processing

After setting the categorization rules, click Next to enter the save location settings. Since the wizard top already shows the subsequent steps as Set save location and Start processing, you can follow the software page prompts to choose where to save the processing results. It is recommended to choose an empty directory or one specifically for output results, making it easier to check the categorized folder structure later and avoiding mixing with the original files.

After confirming the save location, proceed to the Start processing step. Before starting, it is advisable to double-check three key points: first, whether the file list is correct; second, whether the categorization method is By the last few characters; third, whether the number is filled in as 3. After confirming everything is correct, execute the processing, and the software will batch-generate corresponding categorized results based on the filename end characters.

After processing is complete, opening the output directory will show folders like LON, NYC, PAR, SYD, TYO, with files placed into the corresponding folders according to the rules. Thus, an organization task that originally required manual repeated judgment and dragging can be completed quickly through batch processing.

Common Questions and Notes

1. What number should be filled in?

The number depends on how many characters your category identifier has. In the screenshot example, LON, PAR, NYC, SYD, TYO are all 3 English characters, so the number 3 is filled in. If your filename ends with a two-character department code, like 01, 02, 03, then the number should be 2; if it's a four-character project code, like A001, B002, then fill in 4.

2. Do end characters refer to those before the extension or including the extension?

From the results of the screenshot example, it can be reasonably inferred that this categorization uses the characters at the end of the main filename body, i.e., the LON, PAR, etc., before the .txt extension, and does not include the txt extension as part of the category basis. Therefore, when setting up, you should pay attention to whether the category identifier in the main filename body is stable.

3. What if the filename rules are inconsistent?

If some filenames do not have fixed category characters at the end, or the category identifier lengths are inconsistent, the batch categorization results may not meet expectations. It is recommended to first unify the file naming conventions, or import files with consistent rules in batches for processing. For batch materials like office documents, log files, and exported reports, the clearer the naming convention, the better the automatic organization results.

4. Does case affect categorization?

If filenames contain both LON and lon, they might be considered different categories by default. The processing options in the screenshot provide a letter case conversion setting, allowing you to choose Default, Convert to uppercase, or Convert to lowercase as needed. To ensure files of the same category enter the same folder, it is recommended to confirm the case rule before processing.

5. Can only txt files be processed?

No. The screenshot example uses txt files, but categorizing by filename essentially organizes based on filename rules. As long as the filename contains stable end category characters, files like doc, docx, xls, xlsx, pptx, pdf, csv, and images can also be batch-archived using the same approach.

Summary: Replace Manual Dragging with Batch Categorization to Reduce Repetitive Work

Categorizing files by the last few characters of the filename is a very practical office file organization method. It is particularly suitable for scenarios with a large number of files, clear naming rules, and category identifiers fixed at the end of the filename. Through HeSoft Doc Batch Tool , you can first import files, then choose to categorize by the last few characters, fill in the number as 3, and finally set the save location and execute the processing.

Compared to manually creating new folders and moving files one by one, the advantages of batch processing are faster speed, more consistent rules, and a lower probability of error. For users who frequently handle txt logs, Word documents, Excel reports, PDF materials, or other batch files, it is recommended to delegate such rule-based organization tasks to office software, leaving time for tasks that truly require judgment and analysis.


Keyword:Organize files by filename , batch organize files , classify by filename ending characters , classify txt files , batch archive files
Creation Time:2026-07-20 06:39:03

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!