A file name processing method, system and storage medium
Patent Information
- Application Number
- CN202610826780.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-09
- Publication Date
- 2026-09-11
AI Technical Summary
[0004]第一,分隔符无语义:下划线、连字符、空格仅作视觉分隔,不携带类型信息;字段位置需依赖外部约定才能解释,一旦顺序调整或增删字段,既有解析逻辑即告失效
[0033]第一,零成本复用:解析与生成均可直接调用成熟的JSON5工具链,无需自研解析器。
Smart Images

Figure CN122733802A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of filename processing technology, and specifically to a filename processing method, system, and storage medium. Background Technology
[0002] Filenames are the most basic identifying units in a file system, and have long served a dual purpose: to be readable by humans and recognizable by programs. However, existing file naming conventions commonly use flat strings, such as report_2024_v2_final.pdf, Zhang San-Contract-Signature Version.docx, and log_20241015_120345-error.txt.
[0003] The above file naming method has the following defects:
[0004] First, delimiters have no semantic meaning: underscores, hyphens, and spaces only serve as visual separators and do not carry type information; the position of fields depends on external conventions for interpretation, and once the order is adjusted or fields are added or deleted, the existing parsing logic becomes invalid.
[0005] Second, the data types are limited: all information is compressed into strings, making it impossible to directly express nested relationships, arrays, numbers, booleans, or null values. For example, it's difficult to distinguish between "the file's author list is empty" and "author unknown" using traditional naming conventions.
[0006] Third, the parsing methods are scattered: each naming convention requires writing regular expressions or string splitting logic separately, making it impossible to reuse general parsing tools and resulting in high maintenance costs.
[0007] Fourth, metadata is separated from content: Structured data formats such as JSON have good expressive capabilities, but they are usually stored inside files. Users must open the file to read the metadata, and cannot filter, sort, or index without reading the content. Summary of the Invention
[0008] In view of the deficiencies of the prior art mentioned in the background art, the purpose of the embodiments of the present invention is to provide a file name processing method, system and storage medium.
[0009] To achieve the above objectives, in a first aspect, embodiments of the present invention provide a filename processing method, comprising:
[0010] Get the object to be processed;
[0011] The object to be processed is subjected to head and tail removal and concatenation processing to obtain a structured file name body;
[0012] The filename body adopts a syntax that is isomorphic to JSON, supports nested structured structures, including objects, arrays, strings, numbers, booleans, null values, and arbitrary levels of nesting, and supports plain keys and strings with quotes.
[0013] As a specific implementation of this application, the object to be processed is subjected to head and tail removal and concatenation processing to obtain a structured filename body, specifically as follows:
[0014] Remove the closing curly braces from the object to be processed;
[0015] Add the extension .ext to the end of the object to be processed after removing the curly braces to obtain a structured filename body.
[0016] As a preferred implementation of this application, the filename processing method further includes calling a JSON5 parser to parse the filename body and obtain parsed data.
[0017] As one specific implementation of this application, a JSON5 parser is called to parse the filename body to obtain parsed data, specifically:
[0018] The filename body is stripped of its extension and braces are added to obtain the data to be parsed;
[0019] The JSON5 parser is invoked to parse the data to be parsed, resulting in structured parsed data.
[0020] As a specific implementation of this application, the filename body is stripped of its extension, specifically as follows:
[0021] The delimiter closest to the end in the filename body is used as the split line; the delimiter is the origin.
[0022] The filename body is divided into a left part and a right part according to the dividing line to complete the filename body extension stripping; wherein, the right part is the extension ext.
[0023] Secondly, embodiments of the present invention also provide a filename processing system, including a generation end, configured to:
[0024] Get the object to be processed;
[0025] The object to be processed is subjected to head and tail removal and concatenation processing to obtain a structured file name body;
[0026] The filename body adopts a syntax that is isomorphic to JSON, supporting objects, arrays, strings, numbers, booleans, null values, and arbitrary levels of nesting, and also supporting bare key names and strings with quotes.
[0027] As a preferred implementation of this application, the filename processing system further includes a parsing terminal, configured to:
[0028] The filename body is stripped of its extension and braces are added to obtain the data to be parsed;
[0029] The JSON5 parser is invoked to parse the data to be parsed, resulting in structured parsed data.
[0030] Thirdly, embodiments of the present invention also provide a file name processing system, including a processor, an input device, an output device, and a memory, wherein the processor, input device, output device, and memory are interconnected, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to invoke the program instructions to execute the method described in the first aspect.
[0031] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, the computer program including program instructions, which, when executed by a processor, cause the processor to perform the method described in the first aspect.
[0032] The advantages of implementing the embodiments of the present invention are as follows:
[0033] First, zero-cost reuse: both parsing and generation can directly call the mature JSON5 toolchain, without the need to develop a self-developed parser.
[0034] Second, it has complete data types: it supports six basic structures, including strings, numbers, booleans, null values, objects, and arrays, covering the vast majority of metadata scenarios.
[0035] Third, self-descriptive: field semantics are included in the file name along with the key name, without relying on external conventions, which significantly improves readability when collaborating across teams.
[0036] Fourth, indexability: File managers or scripts can directly build indexes, filter, and sort files based on filenames without opening them, improving the efficiency of processing large batches of files.
[0037] Fifth, scalability: When adding a new field, simply append ",k:v" to the original filename; the existing parsing logic does not need to be modified.
[0038] Sixth, readability: Keys are written plainly and values are marked with type, which allows the human eye to quickly identify the fields and their types, which is better than pure string concatenation naming. Attached Figure Description
[0039] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the accompanying drawings used in the description of the specific embodiments or the prior art will be briefly introduced below.
[0040] Figure 1 This is a flowchart of the file name processing method provided in the embodiments of the present invention;
[0041] Figure 2 This is a structural diagram of the file name processing system provided in an embodiment of the present invention;
[0042] Figure 3 yes Figure 2 Another structural diagram of the system shown. Detailed Implementation
[0043] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0044] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0045] The inventive concept of this invention is to directly migrate the structured syntax of JSON to the filename level, making the filename itself a structured record that can be parsed by a machine, thereby eliminating the defects of the prior art described in the background section. This invention defines a new filename naming rule:
[0046] The filename body is treated as an implicit top-level object (the outermost curly braces are omitted), followed by the traditional .ext extension. The body uses a syntax isomorphic to JSON5, supporting objects, arrays, strings, numbers, booleans, null values, and arbitrary levels of nesting. Keys are written plainly, and strings are enclosed in quotes.
[0047] The parsing end can obtain complete structured data by adding curly braces and calling the JSON5 parser; the generation end is the reverse operation.
[0048] This method has extremely low implementation costs, while significantly improving the expressiveness and machine readability of filenames.
[0049] The core rules for implementing this invention are shown in Table 1.
[0050]
[0051] Table 1
[0052] Based on Table 1, examples are given below:
[0053] Example 1: Basic flat structure
[0054] title:"Annual Report",year:2024,pages:120,public:true.pdf
[0055] Represents a publicly released annual report for 2024, with a total of 120 pages.
[0056] Example 2: Mixture of all scalar types
[0057] id:"E001",temperature:-3.14,valid:true,notes:null,retries:0.csv
[0058] It includes five basic types: string, negative decimal, boolean, null value, and integer.
[0059] Example 3: Array field
[0060] project:"AlphaGo",authors:["Li Yi","Wang Er","Zhang San"],languages:["Python","C++"].md
[0061] Both authors and languages are string arrays.
[0062] Example 4: Nested object
[0063] user:"u001",profile:{name:"Zhang San",age:30,vip:true},city:"Beijing".json
[0064] profile is a nested object containing three fields.
[0065] Example 5: Objects nested in array
[0066] class:"Senior Class 1",students:[{name:"Zhang San",score:95},{name:"Li Si",score:88}].json
[0067] It is a student array, and each element is an object.
[0068] Example 6: Deep nesting
[0069] company:"X",dept:{name:"Research and Development",team:{name:"AI",lead:{name:"Wang Wu",age:35}}}.yaml
[0070] The four-level nesting of objects demonstrates the recursive expression capability of the rules.
[0071] Example 7: An empty container represents "known to be empty".
[0072] project:"NewRepo",authors:[],issues:[],meta:{}.md
[0073] Clearly distinguish between "the author list is empty" and "no authors were filled in" (the latter will be written as authors:null).
[0074] Example 8: Experimental Data Type
[0075] experiment:"E042",params:{lr:0.001,batch:64},results:[0.92,0.94,0.95],passed:true.log
[0076] It includes a hyperparameter object, a result array, and pass flags.
[0077] Example 9: Invoice / Document Type
[0078] invoice:"INV-2024-0817",amount:12580.5,paid:false,items:[{sku:"A1",qty:3},{sku:"B2",qty:1}].pdf
[0079] The complete metadata of electronic documents is presented in the file name.
[0080] Example 10: Model checkpoint type
[0081] model:"GPT-mini",epoch:12,loss:0.034,best:true,tags:["v2","prod"].ckpt
[0082] All key metrics of the machine learning training output are embedded in the file name, making it easy to sort and filter by metric.
[0083] Example 11: Log type
[0084] service:"auth",level:"ERROR",code:500,trace:{file:"login.go",line:128},ts:1729000000.log
[0085] The log file carries the service name, level, call stack position, and timestamp.
[0086] Please refer to Figure 1 This is a file name processing method provided in an embodiment of the present invention, which includes the following steps:
[0087] S1, obtain the object to be processed.
[0088] S2, perform head and tail removal and splicing on the object to be processed to obtain a structured file name body.
[0089] In practice, the closing curly braces of the object to be processed are removed; the extension ".ext" is added to the end of the object after removing the curly braces, resulting in a structured filename body. The filename body uses syntax isomorphic to JSON and supports nested structures. Specifically, it supports objects, arrays, strings, numbers, booleans, null values, and arbitrary levels of nesting, and supports plain keys and strings enclosed in quotes.
[0090] It should be noted that the object to be processed can be understood as a file that needs to be named, and can be processed using the naming rules described in step S2. For example, it can be implemented using the following code:
[0091] JSON5.stringify(data) (configured to key without quotes) → removes leading and trailing curly braces {} → concatenates .ext.
[0092] data = { user: "u001", age: 30}
[0093] ext = "json"
[0094] ↓ Call JSON5.stringify
[0095] {user:"u001",age:30}
[0096] Remove the first and last curly braces {}
[0097] user:"u001", age:30
[0098] ↓ Attach .ext
[0099] user:"u001",age:30.json
[0100] S3, call the JSON5 parser to parse the body of the filename and obtain the parsed data.
[0101] In practice, the filename body is stripped of its extension and curly braces are added to obtain the data to be parsed.
[0102] The JSON5 parser is invoked to parse the data to be parsed, resulting in structured parsed data.
[0103] In other words, data parsing only requires two steps:
[0104] Step 1: Strip the file extension, including the curly braces.
[0105] The delimiter closest to the end in the filename body is used as the split line; the delimiter is the origin.
[0106] The filename body is divided into a left part and a right part according to the dividing line to complete the filename body extension stripping; wherein, the right part is the extension ext.
[0107] For example, dividing from the last dot: the right side is ext, and the left side is body.
[0108] json5_str = "{" + body + "}"
[0109] Step 2: Call the JSON5 parser
[0110] data = JSON5.parse(json5_str)
[0111] Finally, it returns (data, ext).
[0112] It should be noted that JSON5 natively supports loose syntax such as bare keys, strings, numbers, booleans, null values, nested objects, and arrays. Therefore, the bare key names in this rule can be directly recognized without any preprocessing.
[0113] For example, the parsing process can be implemented using the following code:
[0114] Input: user:"u001",age:30,tags:["A","B"].json
[0115] ↓ Step 1 (Cut the file extension + wrap it in curly braces)
[0116] json5_str: {user:"u001",age:30,tags:["A","B"]}
[0117] ext: json
[0118] ↓ Step 2 (Call JSON5.parse)
[0119] data:{ user: "u001", age: 30, tags: ["A","B"]}
[0120] The advantages of implementing the file name processing method provided in this embodiment of the invention are as follows:
[0121] First, zero-cost reuse: both parsing and generation can directly call the mature JSON5 toolchain, without the need to develop a self-developed parser.
[0122] Second, it has complete data types: it supports six basic structures, including strings, numbers, booleans, null values, objects, and arrays, covering the vast majority of metadata scenarios.
[0123] Third, self-descriptive: field semantics are included in the file name along with the key name, without relying on external conventions, which significantly improves readability when collaborating across teams.
[0124] Fourth, indexability: File managers or scripts can directly build indexes, filter, and sort files based on filenames without opening them, improving the efficiency of processing large batches of files.
[0125] Fifth, scalability: When adding a new field, simply append ",k:v" to the original filename; the existing parsing logic does not need to be modified.
[0126] Sixth, readability: Keys are written plainly and values are marked with type, which allows the human eye to quickly identify the fields and their types, which is better than pure string concatenation naming.
[0127] Based on the same inventive concept, embodiments of the present invention provide a filename processing system, such as... Figure 2 As shown, it includes the generation end and the parsing end.
[0128] The generation end is configured as follows:
[0129] Get the object to be processed;
[0130] The object to be processed is subjected to head and tail removal and concatenation processing to obtain a structured file name body;
[0131] The filename body adopts a syntax that is isomorphic to JSON, supporting objects, arrays, strings, numbers, booleans, null values, and arbitrary levels of nesting, and also supporting bare key names and strings with quotes.
[0132] More specifically, the generator is configured as follows:
[0133] Remove the closing curly braces from the object to be processed;
[0134] Add the extension .ext to the end of the object to be processed after removing the curly braces to obtain a structured filename body.
[0135] Furthermore, the parsing end is configured as follows:
[0136] The filename body is stripped of its extension and braces are added to obtain the data to be parsed;
[0137] The JSON5 parser is invoked to parse the data to be parsed, resulting in structured parsed data.
[0138] More specifically, the filename body is stripped of its extension, specifically as follows:
[0139] The delimiter closest to the end in the filename body is used as the split line; the delimiter is the origin.
[0140] The filename body is divided into a left part and a right part according to the dividing line to complete the filename body extension stripping; wherein, the right part is the extension ext.
[0141] It should be noted that the specific workflow of this embodiment is described in the foregoing method embodiment section, and will not be repeated here.
[0142] Optionally, such as Figure 3 As shown, another embodiment of the present invention also provides a filename processing system, which may include: one or more processors 101, one or more input devices 102, one or more output devices 103, and a memory 104. The processors 101, input devices 102, output devices 103, and memory 104 are interconnected via a bus 105. The memory 104 is used to store a computer program, the computer program including program instructions, and the processor 101 is configured to invoke the program instructions to execute the method described in the above-described method embodiment.
[0143] It should be understood that, in this embodiment of the invention, the processor 101 may be a central processing unit (CPU), but it may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0144] Input device 102 may include a keyboard, etc., and output device 103 may include a display (LCD, etc.), a speaker, etc.
[0145] The memory 104 may include read-only memory and random access memory, and provides instructions and data to the processor 101. A portion of the memory 104 may also include non-volatile random access memory. For example, the memory 104 may also store device type information.
[0146] In specific implementations, the processor 101, input device 102, and output device 103 described in the embodiments of the present invention can execute the implementation methods described in the embodiments of the file name processing method provided in the embodiments of the present invention, which will not be repeated here.
[0147] Accordingly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, the computer program including program instructions, which, when executed by a processor, implement the above-described file name processing method.
[0148] The computer-readable storage medium can be an internal storage unit of the system described in any of the foregoing embodiments, such as the system's hard disk or memory. The computer-readable storage medium can also be an external storage device of the system, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, the computer-readable storage medium can include both internal storage units and external storage devices. The computer-readable storage medium is used to store the computer program and other programs and data required by the system. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.
[0149] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0150] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices or units, or may be electrical, mechanical or other forms of connection.
[0151] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the embodiments of the present invention, depending on actual needs.
[0152] Furthermore, the functional units in the various embodiments of this invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated units can be implemented in hardware or as software functional units. When using each module, user information is collected and stored only with the user's full authorization and in compliance with relevant laws and regulations, protecting the security and privacy of user data, and strictly prohibiting unauthorized access; data processing will be conducted within the scope stipulated by law and will not exceed the purpose and scope authorized by the user; at the same time, users have the rights to access, correct, delete, restrict processing, and refuse their personal data; and must strictly comply with applicable laws and regulations and conduct compliance reviews.
[0153] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0154] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A filename processing method, characterized in that, include: Get the object to be processed; The object to be processed is subjected to head and tail removal and concatenation processing to obtain a structured file name body; The filename body uses a syntax isomorphic to JSON and supports nested structured structures.
2. The filename processing method as described in claim 1, characterized in that, The object to be processed is subjected to beginning and end removal and concatenation processing to obtain a structured filename body, specifically: Remove the closing curly braces from the object to be processed; Add the extension .ext to the end of the object to be processed after removing the curly braces to obtain a structured filename body.
3. The filename processing method as described in claim 2, characterized in that, The filename body supports objects, arrays, strings, numbers, booleans, null values, and arbitrary levels of nesting, and supports writing keys without quotation marks and strings with quotation marks.
4. The filename processing method as described in claim 3, characterized in that, The filename processing method also includes calling a JSON5 parser to parse the filename body and obtain parsed data.
5. The filename processing method as described in claim 4, characterized in that, The JSON5 parser is invoked to parse the body of the filename, yielding the parsed data, specifically: The filename body is stripped of its extension and braces are added to obtain the data to be parsed; The JSON5 parser is invoked to parse the data to be parsed, resulting in structured parsed data.
6. The filename processing method as described in claim 5, characterized in that, The filename body is stripped of its extension, specifically as follows: The delimiter closest to the end in the filename body is used as the split line; the delimiter is the origin. The filename body is divided into a left part and a right part according to the dividing line to complete the filename body extension stripping; wherein, the right part is the extension ext.
7. A filename processing system, characterized in that, Including the generation end, which is configured as follows: Get the object to be processed; The object to be processed is subjected to head and tail removal and concatenation processing to obtain a structured file name body; The filename body adopts a syntax that is isomorphic to JSON, supporting objects, arrays, strings, numbers, booleans, null values, and arbitrary levels of nesting, and also supporting bare key names and strings with quotes.
8. The filename processing system as described in claim 7, characterized in that, The filename processing system also includes a parsing end, configured as follows: The filename body is stripped of its extension and braces are added to obtain the data to be parsed; The JSON5 parser is invoked to parse the data to be parsed, resulting in structured parsed data.
9. A filename processing system, characterized in that, The system includes a processor, an input device, an output device, and a memory, which are interconnected. The memory is used to store a computer program, which includes program instructions. The processor is configured to invoke the program instructions to execute the method as described in claim 6.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method as described in claim 6.