Batch use file content in the partial text rename TXT file method


Translation:EnglishFrançaisDeutschEspañol日本語한국어,Update Time:2026-05-06 13:29:56

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 TXT text files are still saved with temporary names such as book1.txt and book2.txt, it is time-consuming to manually open one by one, copy the numbers and rename them. This article describes how to use HeSoft Doc Batch Tool , Rename the TXT file in batch according to the specified text in the text file content, for example, extract the number after the Book ID in the first line of each file and use it as the new file name. By adding files, setting regular expression matching rules, selecting overwrite file names and executing processing, multiple text files can be renamed at one time, which is suitable for scenarios such as data archiving, e-book sorting, log file number management, etc.

When sorting out TXT text files, we often encounter such situations: there are a number of files with meaningless names in the folder, such as book1.txt, book2.txt, book3.txt, but each file contains a number, title or name that can be used for archiving. If you open the files one by one, copy the contents, and rename them back to the folder, not only the steps are repeated, but also it is easy to copy errors, omit changes or mess up.

The problem to be solved in this paper is:Batch renaming TXT files using part of the text in the file. Below HeSoft Doc Batch Tool As an example, demonstrate how to extract the numbers after the Book ID in the text content and batch set these numbers as TXT file names.

Applicable Scenarios

Rename text files in bulk using the file contents, suitable for the following scenarios:

  • There are unique numbers in e-books, articles and data files. I hope to use the number as the file name.
  • TXT files such as logs, orders, and contract summaries contain fields such as ID, serial number, and date, and need to be filed by field.
  • The names of downloaded or exported text files are temporary names such as book1.txt and book2.txt, which need to be normalized in batches.
  • There is a fixed format in the file content, suchBook ID:4829173056and want to extract only the numeric part of it as the file name.

HeSoft Doc Batch Tool Is a batch file processing software for office scenarios, the core value is to reduce duplication of operations. For file organizing tasks such as TXT and text data, it allows users to process multiple files at once through rules to avoid repeated opening, copying, pasting and renaming.

Effect Preview: Pre and Post Processing

Before processing: the file name has no actual business meaning.

Before processing, the TXT file name in the folder is similar:

  • book1.txt
  • book2.txt
  • book3.txt
  • book4.txt
  • book5.txt

These names can only indicate the order and cannot directly see the number or content of the file. After opening one of the text files, you can see that the first line of the file content contains something likeBook ID:4829173056of information. What really needs to be used for naming here is the number after the colon4829173056.

image-Batch rename TXT file,use file content rename,text file batch rename

image-Batch rename TXT file,use file content rename,text file batch rename

After processing: Extract the number in the file content as the file name

After batch processing is complete, the file name becomes something like:

  • 1958436720.txt
  • 4829173056.txt
  • 6094728315.txt
  • 7305619482.txt
  • 8640295173.txt

As you can see, each TXT file no longer uses temporary names such as book1 and book2, but is named using the number extracted from the file content. The file extension remains.txtto continue to open and manage as a text file.

image-Batch rename TXT file,use file content rename,text file batch rename

Operation steps

Step 1: Enter the "Rename text file using file content" function

Open HeSoft Doc Batch Tool , select in the left function categoryFile Name. Locate and click in the feature listRename a text file using file contents.

image-Batch rename TXT file,use file content rename,text file batch rename

The purpose of this function is to read the contents of text files in batches and use some text in the contents as file names. In the screenshot, the function is described as "Batch use some text in the content of a text file as the file name of the file", which exactly corresponds to the batch use of TXT content to rename files to be implemented in this article.

After entering this function, the interface will enter the step-by-step wizard, including "select the record to be processed", "set processing options", "set save location", "start processing" and other processes, which can be completed in sequence.

Step 2: Add TXT files that need to be renamed in batches

On the "Select Records to Process" page in Step 1, click at the topAdd Filebutton to add the TXT file that needs to be processed to the list. If the files are collectively saved in the same folder, you can also useImport files from a folder.

image-Batch rename TXT file,use file content rename,text file batch rename

After a file is added, information such as serial number, name, path, extension, creation time, and modification time is displayed in the list. For example, in the screenshot, five text files have been imported from book1.txt to book5.txt, all of which have a txt extension.

The purpose of this step is to let the software know which files to process next. After the addition is completed, check whether the files in the list are correct, and click at the bottom after confirmation.Next step.

Step 3: Set which part of the text to extract from the file content

After entering step 2 "setting processing options", the software needs to be told which area of the TXT file content and according to which rules to extract the text.

image-Batch rename TXT file,use file content rename,text file batch rename

In the Find Area, you can see that there areFirst line of textandCustomize the text that the formula matchesand other options. In this example, although the target content appears in the first line, we only need to extractBook ID:Behind the number, not the entire line of text, so select.Customize the text that the formula matches.

Then fill in the "Regular Expression" input box:

(?<=Book ID:)\d

The meaning of this expression is: find immediately after.Book ID:The following consecutive numbers. to contentBook ID:4829173056For example, the final matching result is4829173056.

If your file content is in a different format, you can adjust the matching rules based on the actual text. For example, if the prefix is not Book ID, but Order ID, number, ID, etc., you need to modify the fixed text in the regular expression accordingly.

Step 4: Set the location where the text is put into the file name

In the Location area of the same page, you can choose how the extracted text is applied to the file name. The following options are available in the screenshot:

  • Overwrite entire file name
  • to the left of the file name
  • to the right of the file name

The goal of this article is to replace the original names book1, book2, etc. with the numbers in the file content, so chooseOverwrite entire file name.

When this option is selected, the software replaces the original file name body with the matched number and retains the text file extension. For example, if 4829173056 is matched in book1.txt, the value becomes 4829173056.txt after processing.

If you just want to append content before or after the original file name, you can select "to the left of the file name" or "to the right of the file name" instead ". However, for the "use the content number as the new file name" requirement for this example, you should choose to overwrite the entire file name.

Step 5: Continue to set the save location and start processing

After completing the extraction rules and named location settings, clickNext stepGo to "Set Save Location". After setting the save location according to the interface wizard, enter Start Processing ".

Since this is a batch rename operation, it is recommended to confirm three points before formal processing:

  • Whether the TXT files in the file list are all files to be processed this time.
  • Whether the regular expression accurately matches the target content.
  • Whether the naming method is selected as Overwrite the entire file name ".

Perform processing after confirmation. After the processing is completed, you can return to the folder to see that the TXT file has been renamed to the number in the content in batch.

Regular expression description: Why use (?<= Book ID :)\d

In this example, the first line of the text file looks like this:

Book ID:4829173056

We only want the number part and don't want to put Book ID: together in the file name, so we used:

(?<=Book ID:)\d

  • (?<=Book ID:): Indicates that the matching position must be preceded by Book ID:, but does not take Book ID: itself as the result.
  • \d: Indicates that one or more numbers are matched.

Therefore, the file name text that the software finally extracts is the number number. This method is suitable for TXT files with fixed content formats, especially when each file contains the same field name but different field values.

Frequently Asked Questions and Precautions

1. What happens if there is no Book ID in the file?

If there is no content in a TXT file that matches the rule, the software cannot extract the new file name according to the rule. It is recommended to sample several documents before processing to confirm that they are similar.Book ID: Numberof the structure.

2. Do regular expressions need to be copied completely?

Not necessarily. This article example appliesBook ID:4829173056this format. If your content is "number: 4829173056" or "id = 4829173056", you need to modify the expression according to the actual prefix.

3. Can the extracted text contain Chinese or titles?

The idea of this function is to extract the specified text from the text file content as the file name. Can be used for renaming as long as the target text can be located through a find region or match rule. In actual use, pay attention to the file name not to contain special characters that are not allowed by the system.

4. Will the contents of the TXT file be changed?

This article demonstrates file name processing, the goal is to modify the file name in batches. Before and after processing, the concern is that the file name is changed from book1.txt to the number. txt, and the file extension is still txt.

5. Do I need a backup before batch processing?

For important data, it is recommended to copy a test folder before batch renaming. After confirming that the rules are correct, then process the official documents. This prevents incorrect rule settings from causing the file name to be unintended.

Summary

Batch use of some text in the file to rename TXT files is essentially to "open the file, find the number, copy the number, return to the folder, modify the file name" this series of repeated actions to the office software to complete automatically. By HeSoft Doc Batch Tool The "Rename Text File with File Content" function of can complete the standard naming of multiple text files at one time by adding files, setting matching rules, selecting overwrite file names and performing processing.

This batch renaming method is recommended if you are organizing a large number of TXT, log, data, and e-book text files, and the contents of the files already contain numbers, titles, or other identifiable fields. It can significantly reduce duplication of work, improve file filing efficiency, but also make the follow-up search and management more clear.


Keyword:Batch rename TXT file , use file content rename , text file batch rename
Creation Time:2026-05-06 13:19:35

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!