A method and device for batch processing of file data
By using regular expressions to match and process hexadecimal data in the .res file in the file data batch processing method, the problem of manual extraction and integration of data is solved, efficient data extraction and integration is achieved, and the efficiency and accuracy of data processing is improved.
Patent Information
- Application Number
- CN202411808929.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-01
AI Technical Summary
In the prior art, manual extraction and integration of hexadecimal data is low efficiency and accuracy, resulting in reduced file batch processing efficiency and accuracy.
Through a batch processing method of file data, the hexadecimal data in the .res file is matched using regular expressions, the matched data is converted into byte data and stored, the file information is generated and stored in a text file, and the data is finally saved as a data.bin file.
It realizes efficient extraction and integration of hexadecimal data in .res file, improves the efficiency and accuracy of data processing, and simplifies the operation process of technicians.
Smart Images

Figure CN119739678A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing technology, and specifically relates to a method and device for batch processing of file data. Background Art
[0002] In the process of software development, it is often necessary to extract data from files of various sources, integrate these data into a unified format, and extract information content from the data that can be used for subsequent development. In actual operation, when processing files containing hexadecimal data, most of the time, relevant technicians have to manually extract and integrate these hexadecimal data. Manual extraction and integration is time-consuming and error-prone, which reduces the efficiency and accuracy of data processing and brings certain difficulties to batch processing of files. Summary of the invention
[0003] In order to solve the problem of low efficiency and accuracy of manual data extraction and integration in the prior art, a method and device for batch processing of file data is provided.
[0004] A method for batch processing of file data, comprising:
[0005] Step 1: Determine whether the current folder contains a .res file. If so, read the file names of all .res files in the current folder and create a file name list based on the file names of all .res files. At the same time, create an empty byte array and an empty text file, and go to step 2. If not, end.
[0006] Step 2: Read the data in all .res files in turn according to the file name list, use regular expressions to match the data in each .res file; convert the matched data into byte data, and store the byte data in a byte array;
[0007] Step 3: traverse the data in the matched .res files, generate file information corresponding to each matched .res file, and store the file information corresponding to each matched .res file in a text file; the file information includes the file name, data size and offset;
[0008] Step 4: Save the matched byte array as data.bin file and save the text file to the current folder.
[0009] Preferably, a device for batch processing of file data comprises: a control module, a data extraction module and a data processing module;
[0010] The control module is used to determine whether the current folder contains a .res file. If so, the control data extraction module reads the file names of all .res files in the current folder and creates a file name list based on the file names of all .res files, and creates an empty byte array and an empty text file at the same time;
[0011] The data extraction module is used to read the data in all .res files in sequence according to the file name list and use regular expressions to match the data in each .res file; convert the matched data into byte data and store the byte data in a byte array;
[0012] The data processing module is used to traverse the data in the matched .res file, generate file information corresponding to each matched .res file, and store the file information corresponding to each matched .res file in a text file; the file information includes the file name, data size and offset information;
[0013] The control module is also used to save the byte array as a data.bin file and save the text file to the current folder after the data processing module stores the file information corresponding to each matched .res file in a text file according to the file name list.
[0014] Beneficial Effects
[0015] A method for batch processing of file data in the present application matches the data in all .res files in the current folder through regular expressions, converts the matched data into byte data and stores it; traverses the data in the matched .res files, generates file information corresponding to each .res file, and stores the file name, data size and offset information corresponding to each .res file in an empty text file; saves the byte array as a data.bin file, and saves the text file to the current folder; this method can effectively extract and integrate the hexadecimal data in the .res file, and relevant technicians can directly view the relevant data through the data.bin file, and the text file provides the .res file related information. This method improves the efficiency and accuracy of data processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 A flowchart of a method for batch processing of file data according to a specific implementation method of the present application;
[0017] Figure 2 A structural diagram of a device for batch processing of file data according to a specific implementation method of the present application. DETAILED DESCRIPTION
[0018] Specific implementation method 1: Combination Figure 1 To explain this embodiment,
[0019] A method for batch processing of file data, comprising:
[0020] Step 1: Determine whether the current folder contains a .res file. If so, read the file names of all .res files in the current folder and create a file name list based on the file names of all .res files. At the same time, create an empty byte array and an empty text file, and go to step 2. If not, end.
[0021] Step 2: Read the data in all .res files in turn according to the file name list, use regular expressions to match the data in each .res file; convert the matched data into byte data, and store the byte data in a byte array;
[0022] Step 3: traverse the data in the matched .res files, generate file information corresponding to each matched .res file, and store the file information corresponding to each matched .res file in a text file; the file information includes the file name, data size and offset;
[0023] Step 4: Save the matched byte array as data.bin file and save the text file to the current folder.
[0024] Specifically, in the actual operation, an empty byte array combined_data is created, and the byte data is appended to combined_data. After all the data is saved, the combined_data array is saved as a data.bin file;
[0025] Create an empty text file file_sizes.txt and store the file information corresponding to each .res file in the empty text file file_sizes.txt.
[0026] According to the file name list, open all .res files in turn to determine whether the data in all .res files are matched. If so, save the byte array as data.bin file and save the text file to the current folder; if there is data in the .res file that has not been matched, return to step 2; ensure that the data in all .res files are matched.
[0027] Furthermore, the data in the .res file is in hexadecimal format.
[0028] Furthermore, the method of using regular expressions to match data in .res files is:
[0029] Match the hexadecimal number in the .res file through the regular expression 0×[0-9a-fA-F]+;
[0030] Among them, 0× represents a character string starting with "0x"; 0-9 represents numbers from 0 to 9, af represents lowercase letters from a to f, and AF represents uppercase letters from A to F.
[0031] Furthermore, the offset is obtained by summing the known starting address of the .res file and the position of the file information corresponding to the .res file in the text file.
[0032] Specific implementation method 2: Combination Figure 2 To explain this embodiment,
[0033] A device for batch processing of file data, comprising: a control module, a data extraction module and a data processing module;
[0034] The control module is used to determine whether the current folder contains a .res file. If so, the control data extraction module reads the file names of all .res files in the current folder and creates a file name list based on the file names of all .res files, and creates an empty byte array and an empty text file at the same time;
[0035] The data extraction module is used to read the data in all .res files in sequence according to the file name list and use regular expressions to match the data in each .res file; convert the matched data into byte data and store the byte data in a byte array;
[0036] The data processing module is used to traverse the data in the matched .res file, generate file information corresponding to each matched .res file, and store the file information corresponding to each matched .res file in a text file; the file information includes the file name, data size and offset information;
[0037] The control module is also used to save the byte array as a data.bin file and save the text file to the current folder after the data processing module stores the file information corresponding to each matched .res file in a text file according to the file name list.
[0038] Furthermore, a file data batch processing device also includes a display module, and the display module is used to receive and display a text file storing file information corresponding to each .res file.
[0039] Furthermore, the data in the .res file is in hexadecimal format.
[0040] Furthermore, the method of using regular expressions to match data in .res files is:
[0041] Match the hexadecimal number in the .res file through the regular expression 0×[0-9a-fA-F]+;
[0042] Among them, 0× represents a character string starting with "0x"; 0-9 represents numbers from 0 to 9, af represents lowercase letters from a to f, and AF represents uppercase letters from A to F.
[0043] Furthermore, the offset is obtained by summing the known starting address of the .res file and the position of the file information corresponding to the .res file in the text file.
[0044] Although the present invention is described herein with reference to specific embodiments, it should be understood that these embodiments are merely examples of the principles and applications of the present invention. It should therefore be understood that many modifications may be made to the exemplary embodiments and that other arrangements may be devised without departing from the spirit and scope of the present invention as defined by the appended claims. It should be understood that the various dependent claims and features described herein may be combined in a manner different from that described in the original claims. It should also be understood that features described in conjunction with individual embodiments may be used in other described embodiments.
Claims
1. A method for batch processing of file data, characterized in that: include: Step 1: Determine whether the current folder contains a .res file. If so, read the file names of all .res files in the current folder and create a file name list based on the file names of all .res files. At the same time, create an empty byte array and an empty text file, and go to step 2. If not, end. Step 2: Read the data in all .res files in turn according to the file name list, use regular expressions to match the data in each .res file; convert the matched data into byte data, and store the byte data in a byte array; Step 3: traverse the data in the matched .res files, generate file information corresponding to each matched .res file, and store the file information corresponding to each matched .res file in a text file; the file information includes the file name, data size and offset; Step 4: Save the matched byte array as data.bin file and save the text file to the current folder.
2. The method for batch processing of file data according to claim 1, characterized in that: The data in the .res file is in hexadecimal format.
3. The method for batch processing of file data according to claim 2, characterized in that: The method of using regular expressions to match data in .res files is: Match the hexadecimal number in the .res file through the regular expression 0×[0-9a-fA-F]+; Among them, 0× represents a character string starting with "0x"; 0-9 represents numbers from 0 to 9, af represents lowercase letters from a to f, and AF represents uppercase letters from A to F.
4. The method for batch processing of file data according to claim 1, characterized in that: The offset is obtained by summing the known starting address of the .res file and the position of the file information corresponding to the .res file in the text file.
5. A device for batch processing of file data, characterized in that: include: Control module, data extraction module and data processing module; The control module is used to determine whether the current folder contains a .res file. If so, the control data extraction module reads the file names of all .res files in the current folder and creates a file name list based on the file names of all .res files, and creates an empty byte array and an empty text file at the same time; The data extraction module is used to read the data in all .res files in sequence according to the file name list and use regular expressions to match the data in each .res file; convert the matched data into byte data and store the byte data in a byte array; The data processing module is used to traverse the data in the matched .res file, generate file information corresponding to each matched .res file, and store the file information corresponding to each matched .res file in a text file; the file information includes the file name, data size and offset information; The control module is also used to save the byte array as a data.bin file and save the text file to the current folder after the data processing module stores the file information corresponding to each matched .res file in a text file according to the file name list.
6. The file data batch processing device according to claim 5, characterized in that: The system also includes a display module, which is used to receive and display a text file storing file information corresponding to each .res file.
7. The file data batch processing device according to claim 5, characterized in that: The data in the .res file is in hexadecimal format.
8. The file data batch processing device according to claim 5, characterized in that: The method of using regular expressions to match data in .res files is: Match the hexadecimal number in the .res file through the regular expression 0×[0-9a-fA-F]+; Among them, 0× represents a character string starting with "0x"; 0-9 represents numbers from 0 to 9, af represents lowercase letters from a to f, and AF represents uppercase letters from A to F.
9. The file data batch processing device according to claim 5, characterized in that: The offset is obtained by summing the known starting address of the .res file and the position of the file information corresponding to the .res file in the text file.