When file names consist of a number followed by a city code, for example 10102271LON.txt, 10103956PAR.txt, if all files are mixed together in one directory, subsequent searching and delivery can be very troublesome. This article explains how to use HeSoft Doc Batch Tool to automatically create folders such as LON, PAR, NYC, SYD, TYO based on the city code after the file name number, and batch archive the corresponding files.
Files exported from many business systems often use a naming convention of "serial number + classification code". The serial number ensures file uniqueness, while the code after it identifies the city, region, store, department, or project. For example, in files like 10102271LON.txt, 10103956PAR.txt, and 10166063SYD.txt, the first part is the serial number, and the last 3 letters are the classification information truly used for archiving.
The problem is that file systems don't automatically understand these codes. If all files are placed in the same directory, users still need to manually sort them by LON, PAR, NYC, SYD, TYO. This article will introduce how to use office software like HeSoft Doc Batch Tool to identify the city code at the end of the filename, bulk-create corresponding folders, and automatically sort the files into them. This method is suitable for a large volume of txt text files, and also for the batch sorting of common office files like doc, docx, xls, xlsx, and pdf.
Applicable Scenario: Files with City or Classification Codes After the Serial Number
When the file name structure is relatively uniform, sorting by the last characters is the most suitable method. Examples include "Order Number + City Code", "Customer Number + Region Code", "Device Number + Site Code", "Contract Number + Project Code", etc. The classification information the user truly cares about is not at the beginning of the filename, but in a fixed position at the end.
Using the screenshots in this article as an example, the LON, PAR, NYC, SYD, and TYO in the filenames are all 3-letter codes located just before the extension. If you were to sort such files manually, you would need to create an LON folder, search for all LON files and move them in, and then repeat for PAR, NYC, SYD, TYO. The more categories and files there are, the more repetitive the labor becomes.
After using a batch processing tool, you can set the rule to "read the last 3 characters and sort by those characters". The software will automatically complete the identification, folder creation, and archiving actions. For roles that need to regularly organize downloaded files, system exports, or files delivered by suppliers, this method makes file archiving more standardized and easier to reuse.
Result Preview: All City Code Files Mixed Together Before Processing
In the directory before processing, all txt files are arranged together. Although the city code is already in the filename, from the folder structure perspective, the files have not been differentiated.

The area marked in red in the screenshot shows the 3-character code at the end of the filename. For example, the archiving basis for the first file, 10102271LON.txt, is LON, and for the second file, 10103956PAR.txt, it is PAR. As long as these codes have a consistent length, the software can be instructed to extract a fixed number of characters from the end.
Result Preview: City Code Folders Automatically Generated After Processing
After the processing is complete, the originally intermixed files are sorted into multiple folders. You can see folders like LON, NYC, PAR, SYD, TYO appear in the target directory, and these folder names precisely correspond to the city codes at the end of the filenames.

This structure is better suited for office archiving. Subsequently, if you need to compile data for a specific city, compress a certain type of file to send to a colleague, or back up only one category of data, you can directly access the corresponding folder for operations, eliminating the need to filter through a large number of files.
Operation Steps: From Importing Files to Automatic Archiving by City Code
Step 1: Open the File Organization Module
After entering HeSoft Doc Batch Tool , the left navigation bar provides multiple tool categories. Since the task here is to organize file locations, not to edit document content, select File Organization.

On the File Organization page, select Sort files by filename. This function is used for batch sorting files based on filename patterns, perfectly fitting the archiving need for "city code after the serial number". After selecting it, you'll enter the operation wizard; simply complete the subsequent process.
The expected result of this step is to enter the correct task page. If you mistakenly select "Sort files by extension", the software will classify them by format like txt, docx, pdf, not by LON, PAR, NYC. Therefore, be sure to confirm you've selected sorting by filename.
Step 2: Batch Import the Files to Be Archived
In the first step of the processing page, "Select records to process", you can click Add files or Import files from folder. If all these files are located in the same directory, such as D:\test in the screenshot, using "Import files from folder" is more convenient.

After importing, the file information will be displayed in a list. The list contains columns for Name, Path, Extension, Creation Time, Modification Time, etc. It's recommended to check three key points here: First, whether the number of records matches expectations; second, whether the path points to the correct folder; third, whether the end of each filename contains the city code that needs categorization.
The record count in the screenshot is 20, indicating that the pending files have been successfully added. The Name column shows multiple different suffixes, such as LON, PAR, SYD, NYC, TYO. Once confirmed, click Next at the bottom to enter the processing options setup.
Step 3: Sort by the Last 3 Characters
After entering "Set processing options", you'll see various classification methods. Since the city code is at the end of the filename, select Sort by the last few characters.

Enter 3 in the "Number" input box. This 3 corresponds to the length of the city code: LON, PAR, NYC, SYD, TYO are all 3-letter codes. Based on this number, the software will extract characters from the end of the filename's main body and use the extracted result as the name of the classification folder.
For example, 10166063SYD.txt will be identified as belonging to the SYD class, 10202656TYO.txt as TYO, and 10359600PAR.txt as PAR. As long as the rule is consistent, there's no need to individually specify which folder each file should go to.
There is also a "Letter case conversion" option at the bottom of the page. The example keeps it "Default", meaning the original letter case of the filename suffix is not changed. If your actual files have mixed cases like lon, Lon, LON, and you want them all grouped into the LON folder, you can combine the case conversion options provided in the interface for unification. If the file naming is already standardized, keeping the default setting is fine.
Step 4: Select Output Location and Execute
After setting the classification rules, continue by clicking Next. Following the top workflow, the next step is Set save location. It is recommended to save the results to a new target directory, such as a folder named "City Code Classification Results", for easy distinction from the original files.
After the save location is confirmed, you will enter the Start processing phase. The software will automatically create folders based on the last 3 characters of the filenames and sort the corresponding files into them. Upon completion, you will see a folder structure named with city codes, like LON, PAR, NYC, SYD, TYO.
This step completes the final archiving action. For the user, there is no need to manually create all city folders beforehand or search for files category by category. The software executes batch processing according to the rules, making it especially suitable for office workflows that require repeated processing of similar files.
Common Questions and Precautions
1. What if the city code is not 3 characters?
If your city or classification code is not 3 characters long, just enter the actual length in the "Number" field. For example, if the suffix is a 2-character code like BJ, SH, GZ, enter 2; if it's a 4-character code like AREA, SALE, enter 4. The entered number must match the length of the code to be extracted.
2. Will different lengths for the preceding serial number affect the process?
Generally, no. Because this method extracts characters from the end moving backward, the length of the preceding serial numbers can vary. As long as the classification code is fixed at the end of the filename and its length is consistent, sorting by the last characters works.
3. Can files with different extensions be processed together?
They can be processed together based on actual needs. Sorting by filename focuses on the classification characters in the name, not the extension. For instance, if 10102271LON.docx, 10102272LON.pdf, and 10102273LON.xlsx all end with the code LON, they can be placed into the LON folder. However, it's still advisable to confirm consistent naming rules before processing to prevent unrelated files from being mixed in.
4. Will the processed folder names be exactly the last characters?
Judging from the example results, the processed folder names are the characters extracted from the filename suffix, such as LON, NYC, PAR, SYD, TYO. Therefore, when setting the number, ensure the extraction result is exactly the classification name you want to see.
5. How to reduce risk when using it for the first time?
It's advisable to first copy a small number of sample files for testing. After confirming that LON files indeed go into the LON folder and PAR files into the PAR folder, you can then perform batch processing on the complete directory. Additionally, it's best to select a new directory for the output location to make verification and rollback easier.
Summary: How to Automatically Form a Clear Directory for Serialized Files Based on the Suffix Code
Files with a serial number followed by a city code are common, but without tool assistance, organizing them is highly repetitive. Using the "Sort files by filename" function in HeSoft Doc Batch Tool , you can create folders based on the last few characters of the filename and automatically archive the files into them. In the example in this article, after entering the number 3, the files were sorted into folders like LON, NYC, PAR, SYD, TYO, resulting in a clear directory structure at a glance.
If you have a large number of files named with serial numbers and ending with classification codes, you can follow the steps in this article: go to File Organization, choose to sort by filename, import the files, set "Sort by the last few characters," enter the code length, set the save location, and start processing. This way, you can hand over the work of extensive manual filtering to office software, reducing errors and improving file archiving efficiency.