[go: up one dir, main page]

CN106933967B - Batch modification method and device for file contents - Google Patents

Batch modification method and device for file contents Download PDF

Info

Publication number
CN106933967B
CN106933967B CN201710071896.6A CN201710071896A CN106933967B CN 106933967 B CN106933967 B CN 106933967B CN 201710071896 A CN201710071896 A CN 201710071896A CN 106933967 B CN106933967 B CN 106933967B
Authority
CN
China
Prior art keywords
file
content
source
line
source file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710071896.6A
Other languages
Chinese (zh)
Other versions
CN106933967A (en
Inventor
舒奥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiamen Hanyang Chuangyi Cultural Media Co ltd
Original Assignee
Yulong Computer Telecommunication Scientific Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Yulong Computer Telecommunication Scientific Shenzhen Co Ltd filed Critical Yulong Computer Telecommunication Scientific Shenzhen Co Ltd
Priority to CN201710071896.6A priority Critical patent/CN106933967B/en
Publication of CN106933967A publication Critical patent/CN106933967A/en
Application granted granted Critical
Publication of CN106933967B publication Critical patent/CN106933967B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/162Delete operations
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Human Computer Interaction (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a batch modification method of file contents and a batch modification method of the file contents, wherein the batch modification method of the file contents comprises the following steps: receiving a modification instruction of at least one source file in any file directory; searching each source file in at least one source file line by line according to the modification instruction, and detecting whether the source file content of each line has content to be modified; when the content to be modified is found in the source file content of any line, the content to be modified is updated to be the replacement content, the modified file content of any line is copied to the corresponding position of the intermediate file, otherwise, the source file content of any line is copied to the corresponding position of the intermediate file; and after the searching and updating of the source file content of the last line of each source file are completed, correspondingly replacing all the source file content in each source file with the file content in the intermediate file. The technical scheme can effectively improve the working efficiency and accuracy of modifying the file contents in batches.

Description

文件内容的批量修改方法及批量修改装置Batch modification method and batch modification device for file content

技术领域technical field

本发明涉及终端技术领域,具体而言,涉及一种文件内容的批量修改方法和一种文件内容的批量修改装置。The present invention relates to the technical field of terminals, in particular to a method for batch modification of file content and a device for batch modification of file content.

背景技术Background technique

目前,当用户需要一次性修改很多文件中的相同内容时,只能够手动打开一个个的文件,然后再一个一个的找到需要修改的内容将之修改为所需的内容,这样需要使用人工手动更改大批量文件的内容;但是,有的时候这些文件的个数可能成千上万,这时对于用户来说,是一项非常浩大的工程,不仅费时费力,还不能够保证每一个需要修改的内容都得到了正确的修改,而且这个工作很乏味,容易让人产生疲劳感,给用户带来了很不好的体验。At present, when users need to modify the same content in many files at once, they can only manually open the files one by one, and then find the content that needs to be modified one by one and modify it to the desired content, which requires manual modification. The content of a large number of files; however, sometimes the number of these files may be tens of thousands. At this time, it is a very large project for users, which is not only time-consuming and laborious, but also cannot guarantee the The content has been corrected, and the work is tedious, tiring, and a bad user experience.

发明内容Contents of the invention

本发明正是基于上述技术问题至少之一,提出了一种新的文件内容的批量修改方案,可以有效地提高批量修改文件内容的工作效率和准确度。Based on at least one of the above technical problems, the present invention proposes a new solution for batch modification of file content, which can effectively improve the work efficiency and accuracy of batch modification of file content.

有鉴于此,根据本发明的第一方面,提出了一种文件内容的批量修改方法,包括:接收对任一文件目录下的至少一个源文件的修改指令;根据所述修改指令对所述至少一个源文件中的每个源文件进行逐行查找,检测每行的源文件内容中是否存在待修改内容;当在任一行的源文件内容中查找到所述待修改内容时,将所述待修改内容更新为替换内容,并将所述任一行的修改后的文件内容复制到中间文件的对应位置,否则将所述任一行的源文件内容复制到所述中间文件的对应位置;在完成对所述每个源文件的最后一行的源文件内容的查找更新后,将所述每个源文件中的所有源文件内容对应替换为所述中间文件中的文件内容。In view of this, according to the first aspect of the present invention, a batch modification method for file content is proposed, including: receiving a modification instruction for at least one source file under any file directory; modifying the at least one source file according to the modification instruction Each source file in a source file is searched line by line to detect whether there is content to be modified in the source file content of each line; when the content to be modified is found in the source file content of any line, the content to be modified will be The content is updated to replace the content, and the modified file content of any line is copied to the corresponding position of the intermediate file, otherwise the source file content of any line is copied to the corresponding position of the intermediate file; After searching and updating the source file content in the last line of each source file, all the source file content in each source file is correspondingly replaced with the file content in the intermediate file.

在该技术方案中,当确定需要进行文件内容的批量修改的文件目录时,对该文件目录下包含的所有源文件中的每个源文件执行自动逐行查找其源文件内容中是否存在待修改内容的,如果在查找每个源文件的每一行源文件内容时发现存在该待修改的内容,则在自动将其更新为替换内容后将该行修改后的文件内容复制到一中间文件的对应位置进行存储,而如果在查找每个源文件的每一行源文件内容时未发现该待修改的内容,则自动将该行的源文件内容复制到该中间文件的对应位置进行存储,如此直至查找更新完每个源文件的最后一行的源文件内容后,将该每个源文件中的内容对应替换为中间文件中存储的文件内容,从而完成对每个源文件的逐行查找更新,上述技术方案通过对任一文件目录下的所有源文件自动查找待修改内容并替换为用户需要的内容,可以有效地提高批量修改文件内容的工作效率和准确度。In this technical scheme, when the file directory that needs to be modified in batches is determined, each source file in all source files contained in the file directory is automatically searched line by line for whether there is a file to be modified in the source file content. content, if it is found that there is content to be modified when searching for each line of source file content in each source file, copy the modified file content of this line to the corresponding intermediate file after it is automatically updated to replace the content location, and if the content to be modified is not found when searching for each line of source file content of each source file, the source file content of this line is automatically copied to the corresponding position of the intermediate file for storage, and so on until the search After updating the source file content of the last line of each source file, replace the content in each source file with the file content stored in the intermediate file, so as to complete the line-by-line search and update of each source file. The above technology The solution can effectively improve the work efficiency and accuracy of batch modification of file content by automatically searching for the content to be modified and replacing it with the content required by the user for all source files in any file directory.

在上述技术方案中,优选地,所述将所述每个源文件中的所有源文件内容对应替换为所述中间文件中的文件内容的步骤包括:将每个源文件中的所有源文件内容逐行依次对应替换为所述中间文件中的文件内容。In the above technical solution, preferably, the step of correspondingly replacing all source file content in each source file with the file content in the intermediate file includes: replacing all source file content in each source file Line by line and correspondingly replace with the file content in the intermediate file.

在该技术方案中,完成对每个源文件中的所有行的源文件内容的查找更新后,在将源文件中的所有源文件内容对应替换为临时建立的中间文件中存储的文件内容时,可以仍采用逐行进行替换的方式,以确保文件内容修改更新的准确度,从而提升用户体验。In this technical solution, after completing the searching and updating of the source file content of all lines in each source file, when all the source file content in the source file is correspondingly replaced with the file content stored in the temporarily created intermediate file, The method of replacing line by line may still be used to ensure the accuracy of file content modification and update, thereby improving user experience.

在上述任一技术方案中,优选地,在所述将所述每个源文件中的所有源文件内容对应替换为所述中间文件中的文件内容后,所述文件内容的批量修改方法还包括:删除所述中间文件。In any of the above technical solutions, preferably, after the corresponding replacement of all source file contents in each source file with the file contents in the intermediate file, the method for modifying file contents in batches further includes : delete the intermediate file.

在该技术方案中,为了避免临时建立的中间文件存在多个容易导致文件内容修改更新混乱的问题,在完成对每个源文件的文件内容的修改更新后即可以将该中间文件删除,同时节省其占用的存储空间。In this technical solution, in order to avoid multiple problems in the temporarily established intermediate file that may easily lead to confusion in the modification and update of the file content, the intermediate file can be deleted after the modification and update of the file content of each source file is completed, and at the same time saving The storage space it occupies.

另一方面,也可以采用将中间文件中存储的文件内容清空的方式,以将该中间文件继续用于对下一个源文件的文件内容进行自动查找、修改更新的过程中,节省操作时间的同时也可以达到节省存储空间的目的。On the other hand, it is also possible to use the method of clearing the file content stored in the intermediate file, so as to continue to use the intermediate file in the process of automatically searching, modifying and updating the file content of the next source file, saving operation time and at the same time It can also achieve the purpose of saving storage space.

在上述任一技术方案中,优选地,所述接收对任一文件目录下的至少一个源文件的修改指令的步骤,还包括:扫描所述任一文件目录,确定所述任一文件目录中是否包括至少一个子目录;以及当确定所述任一文件目录中包括至少一个子目录时,所述根据所述修改指令对所述至少一个源文件中的每个源文件进行逐行查找的步骤,具体包括:根据所述修改指令循环访问所述至少一个子目录中的所有子目录,依次对每个子目录中包含的源文件进行逐行查找。In any of the above technical solutions, preferably, the step of receiving a modification instruction for at least one source file under any file directory further includes: scanning the any file directory, and determining the Whether at least one subdirectory is included; and when it is determined that at least one subdirectory is included in the any file directory, the step of performing a line-by-line search for each source file in the at least one source file according to the modification instruction , specifically comprising: iteratively accessing all subdirectories in the at least one subdirectory according to the modification instruction, and sequentially searching the source files contained in each subdirectory line by line.

在该技术方案中,当确定需要进行文件内容的批量修改的文件目录,首先可以逐层扫描遍历该文件目录以确定其是否包含子目录,若包含则对该文件目录下的每个子目录进行逐层遍历直至查找到其中的源文件,即以下层包含源文件的子目录为处理单位,依次完成每个子目录中包含的源文件的修改,继而完成对文件目录下包含的所有源文件的源文件内容的修改,以避免出现文件遗漏未修改的情况。In this technical scheme, when determining the file directory that needs to be modified in batches, the file directory can first be scanned and traversed layer by layer to determine whether it contains subdirectories. Layer traversal until the source files in it are found, that is, the subdirectories containing source files in the lower layer are used as the processing unit, and the source files contained in each subdirectory are modified in turn, and then the source files of all source files contained in the file directory are completed. Modify the content to avoid the situation that the file is missing and not modified.

在上述任一技术方案中,优选地,还包括:当完成对当前子目录中的当前源文件的修改后,判断是否处理完所述当前子目录中包含的所有源文件;若未处理完所述当前子目录中包含的所有源文件,则对所述当前子目录中的下一个源文件中的源文件内容进行查找更新,否则判断是否处理完所述所有子目录;若未处理完所述所有子目录,则对所述所有子目录中的下一子目录中包含的源文件进行逐行查找,直至处理完所述所有子目录,否则显示批量修改完成。In any of the above technical solutions, preferably, it also includes: after completing the modification of the current source file in the current subdirectory, judging whether all the source files contained in the current subdirectory have been processed; If all the source files contained in the current subdirectory are mentioned above, the source file content in the next source file in the current subdirectory is searched and updated, otherwise it is judged whether all the subdirectories have been processed; For all subdirectories, the source files contained in the next subdirectory in all the subdirectories are searched line by line until all the subdirectories are processed, otherwise it is displayed that the batch modification is completed.

在该技术方案中,当完成一个子目录下的一个源文件的内容修改后,判断该子目录中包含的所有源文件是否均完成了内容修改,即确定该源文件是否为该子目录中的最后一个源文件,如果不是则继续对该子目录下的下一个源文件进行内容修改,否则判断是否处理完了文件目录下包含的所有子目录,即确定该子目录是否为文件目录下的最后一个子目录,若不是则继续处理下一个子目录中的源文件,直至处理完所有的源文件,否则若该子目录为文件目录下的最后一个子目录,则提示用户对该文件目录下的所有源文件的源文件内容的批量修改已完成,即通过递归查找搜索的方式完成文件内容的高效地批量修改,降低了出错率提高了工作效率。In this technical solution, after the content modification of a source file in a subdirectory is completed, it is judged whether all source files contained in the subdirectory have completed content modification, that is, it is determined whether the source file is a source file in the subdirectory. The last source file, if not, continue to modify the content of the next source file in the subdirectory, otherwise judge whether all the subdirectories contained in the file directory have been processed, that is, determine whether the subdirectory is the last one in the file directory subdirectory, if not, continue to process the source files in the next subdirectory until all the source files are processed, otherwise, if the subdirectory is the last subdirectory under the file directory, prompt the user for all the source files under the file directory The batch modification of the source file content of the source file has been completed, that is, the efficient batch modification of the file content is completed by means of recursive search and search, which reduces the error rate and improves work efficiency.

根据本发明的第二方面,提出了一种文件内容的批量修改装置,包括:输入模块,用于接收对任一文件目录下的至少一个源文件的修改指令;遍历模块,用于根据所述输入模块接收的所述修改指令对所述至少一个源文件中的每个源文件进行逐行查找,检测每行的源文件内容中是否存在待修改内容;修改模块,用于当所述遍历模块在任一行的源文件内容中查找到所述待修改内容时,将所述待修改内容更新为替换内容,并将所述任一行的修改后的文件内容复制到中间文件的对应位置,否则将所述任一行的源文件内容复制到所述中间文件的对应位置;处理模块,用于在完成对所述每个源文件的最后一行的源文件内容的查找更新后,将所述每个源文件中的所有源文件内容对应替换为所述中间文件中的文件内容。According to the second aspect of the present invention, a batch modification device for file content is proposed, including: an input module for receiving modification instructions for at least one source file under any file directory; a traversal module for The modification instruction received by the input module searches each source file in the at least one source file line by line, and detects whether there is content to be modified in the source file content of each line; the modification module is used when the traversal module When the content to be modified is found in the source file content of any line, the content to be modified is updated to the replacement content, and the modified file content of any line is copied to the corresponding position of the intermediate file, otherwise all Copy the source file content of any line to the corresponding position of the intermediate file; the processing module is used to copy each source file to the source file content of the last line of each source file All source file content in is replaced with the file content in the intermediate file.

在该技术方案中,当确定需要进行文件内容的批量修改的文件目录时,对该文件目录下包含的所有源文件中的每个源文件执行自动逐行查找其源文件内容中是否存在待修改内容的,如果在查找每个源文件的每一行源文件内容时发现存在该待修改的内容,则在自动将其更新为替换内容后将该行修改后的文件内容复制到一中间文件的对应位置进行存储,而如果在查找每个源文件的每一行源文件内容时未发现该待修改的内容,则自动将该行的源文件内容复制到该中间文件的对应位置进行存储,如此直至查找更新完每个源文件的最后一行的源文件内容后,将该每个源文件中的内容对应替换为中间文件中存储的文件内容,从而完成对每个源文件的逐行查找更新,上述技术方案通过对任一文件目录下的所有源文件自动查找待修改内容并替换为用户需要的内容,可以有效地提高批量修改文件内容的工作效率和准确度。In this technical scheme, when the file directory that needs to be modified in batches is determined, each source file in all source files contained in the file directory is automatically searched line by line for whether there is a file to be modified in the source file content. content, if it is found that there is content to be modified when searching for each line of source file content in each source file, copy the modified file content of this line to the corresponding intermediate file after it is automatically updated to replace the content location, and if the content to be modified is not found when searching for each line of source file content of each source file, the source file content of this line is automatically copied to the corresponding position of the intermediate file for storage, and so on until the search After updating the source file content of the last line of each source file, replace the content in each source file with the file content stored in the intermediate file, so as to complete the line-by-line search and update of each source file. The above technology The solution can effectively improve the work efficiency and accuracy of batch modification of file content by automatically searching for the content to be modified and replacing it with the content required by the user for all source files in any file directory.

在上述技术方案中,优选地,所述处理模块具体用于:将每个源文件中的所有源文件内容逐行依次对应替换为所述中间文件中的文件内容。In the above technical solution, preferably, the processing module is specifically configured to: replace all source file contents in each source file line by line with the file content in the intermediate file.

在该技术方案中,完成对每个源文件中的所有行的源文件内容的查找更新后,在将源文件中的所有源文件内容对应替换为临时建立的中间文件中存储的文件内容时,可以仍采用逐行进行替换的方式,以确保文件内容修改更新的准确度,从而提升用户体验。In this technical solution, after completing the searching and updating of the source file content of all lines in each source file, when all the source file content in the source file is correspondingly replaced with the file content stored in the temporarily created intermediate file, The method of replacing line by line may still be used to ensure the accuracy of file content modification and update, thereby improving user experience.

在上述任一技术方案中,优选地,还包括:删除模块,用于在所述处理模块将所述每个源文件中的所有源文件内容对应替换为所述中间文件中的文件内容后,删除所述中间文件。In any of the above technical solutions, preferably, further comprising: a deletion module, configured to replace all source file contents in each source file with file contents in the intermediate file by the processing module, Delete said intermediate file.

在该技术方案中,为了避免临时建立的中间文件存在多个容易导致文件内容修改更新混乱的问题,在完成对每个源文件的文件内容的修改更新后即可以将该中间文件删除,同时节省其占用的存储空间。In this technical solution, in order to avoid multiple problems in the temporarily established intermediate file that may easily lead to confusion in the modification and update of the file content, the intermediate file can be deleted after the modification and update of the file content of each source file is completed, and at the same time saving The storage space it occupies.

另一方面,也可以采用将中间文件中存储的文件内容清空的方式,以将该中间文件继续用于对下一个源文件的文件内容进行自动查找、修改更新的过程中,节省操作时间的同时也可以达到节省存储空间的目的。On the other hand, it is also possible to use the method of clearing the file content stored in the intermediate file, so as to continue to use the intermediate file in the process of automatically searching, modifying and updating the file content of the next source file, saving operation time and at the same time It can also achieve the purpose of saving storage space.

在上述任一技术方案中,优选地,所述输入模块包括:遍历子模块,用于扫描所述任一文件目录,确定所述任一文件目录中是否包括至少一个子目录;以及所述遍历模块具体还用于:当所述遍历子模块确定所述任一文件目录中包括至少一个子目录时,根据所述修改指令循环访问所述至少一个子目录中的所有子目录,依次对每个子目录中包含的源文件进行逐行查找。In any of the above technical solutions, preferably, the input module includes: a traversal submodule, configured to scan any file directory and determine whether at least one subdirectory is included in any file directory; and the traversal The module is also specifically configured to: when the traversal submodule determines that at least one subdirectory is included in the any file directory, iterate through all subdirectories in the at least one subdirectory according to the modification instruction, and sequentially search for each subdirectory The source files contained in the directory are searched line by line.

在该技术方案中,当确定需要进行文件内容的批量修改的文件目录,首先可以逐层扫描遍历该文件目录以确定其是否包含子目录,若包含则对该文件目录下的每个子目录进行逐层遍历直至查找到其中的源文件,即以下层包含源文件的子目录为处理单位,依次完成每个子目录中包含的源文件的修改,继而完成对文件目录下包含的所有源文件的源文件内容的修改,以避免出现文件遗漏未修改的情况。In this technical scheme, when determining the file directory that needs to be modified in batches, the file directory can first be scanned and traversed layer by layer to determine whether it contains subdirectories. Layer traversal until the source files in it are found, that is, the subdirectories containing source files in the lower layer are used as the processing unit, and the source files contained in each subdirectory are modified in turn, and then the source files of all source files contained in the file directory are completed. Modify the content to avoid the situation that the file is missing and not modified.

在上述任一技术方案中,优选地,还包括:判断模块,用于当完成对当前子目录中的当前源文件的修改后,判断是否处理完所述当前子目录中包含的所有源文件;控制模块,用于当所述判断模块判定未处理完所述当前子目录中包含的所有源文件,则控制对所述当前子目录中的下一个源文件中的源文件内容进行查找更新,否则控制所述判断模块判断是否处理完所述所有子目录;以及所述控制模块还用于:用当所述判断模块判定未处理完所述所有子目录,则控制对所述所有子目录中的下一子目录中包含的源文件进行逐行查找,直至处理完所述所有子目录,否则控制显示批量修改完成。In any of the above technical solutions, preferably, further comprising: a judging module, configured to judge whether all source files contained in the current subdirectory have been processed after the modification of the current source file in the current subdirectory is completed; A control module, used for controlling to search and update the content of the source file in the next source file in the current subdirectory when the judging module determines that all source files contained in the current subdirectory have not been processed, otherwise Controlling the judging module to judge whether all subdirectories have been processed; and the control module is also used for: when the judging module judges that all subdirectories have not been processed, then control the processing of all subdirectories The source files contained in the next subdirectory are searched line by line until all subdirectories are processed, otherwise the control display batch modification is completed.

在该技术方案中,当完成一个子目录下的一个源文件的内容修改后,判断该子目录中包含的所有源文件是否均完成了内容修改,即确定该源文件是否为该子目录中的最后一个源文件,如果不是则继续对该子目录下的下一个源文件进行内容修改,否则判断是否处理完了文件目录下包含的所有子目录,即确定该子目录是否为文件目录下的最后一个子目录,若不是则继续处理下一个子目录中的源文件,直至处理完所有的源文件,否则若该子目录为文件目录下的最后一个子目录,则提示用户对该文件目录下的所有源文件的源文件内容的批量修改已完成,即通过递归查找搜索的方式完成文件内容的高效地批量修改,降低了出错率提高了工作效率。In this technical solution, after the content modification of a source file in a subdirectory is completed, it is judged whether all source files contained in the subdirectory have completed content modification, that is, it is determined whether the source file is a source file in the subdirectory. The last source file, if not, continue to modify the content of the next source file in the subdirectory, otherwise judge whether all the subdirectories contained in the file directory have been processed, that is, determine whether the subdirectory is the last one in the file directory subdirectory, if not, continue to process the source files in the next subdirectory until all the source files are processed, otherwise, if the subdirectory is the last subdirectory under the file directory, prompt the user for all the source files under the file directory The batch modification of the source file content of the source file has been completed, that is, the efficient batch modification of the file content is completed by means of recursive search and search, which reduces the error rate and improves work efficiency.

根据本发明的第三方面,提出了一种终端,包括上述技术方案中任一项所述的文件内容的批量修改装置,因此,该终端具有该文件内容的批量修改装置所有的有益效果,在此不再赘述。According to the third aspect of the present invention, a terminal is proposed, including the device for batch modification of file content described in any one of the above technical solutions. Therefore, the terminal has all the beneficial effects of the device for batch modification of file content. This will not be repeated here.

根据本发明的第四方面,提出了一种终端,包括:处理器、输入装置、输出装置和存储器,其中,According to a fourth aspect of the present invention, a terminal is proposed, including: a processor, an input device, an output device, and a memory, wherein,

存储器用于存储一组程序代码;The memory is used to store a set of program codes;

处理器调用存储器中存储的程序代码,用于执行以下操作:The processor invokes program code stored in memory to perform the following operations:

通过输入装置接收对任一文件目录下的至少一个源文件的修改指令;receiving a modification instruction to at least one source file in any file directory through an input device;

根据所述修改指令对所述至少一个源文件中的每个源文件进行逐行查找,检测每行的源文件内容中是否存在待修改内容;Search each source file in the at least one source file line by line according to the modification instruction, and detect whether there is content to be modified in the source file content of each line;

当在任一行的源文件内容中查找到所述待修改内容时,将所述待修改内容更新为替换内容,并将所述任一行的修改后的文件内容复制到中间文件的对应位置,否则将所述任一行的源文件内容复制到所述中间文件的对应位置;When the content to be modified is found in the source file content of any row, the content to be modified is updated to replace the content, and the modified file content of any row is copied to the corresponding position of the intermediate file, otherwise the The source file content of any line is copied to the corresponding position of the intermediate file;

在完成对所述每个源文件的最后一行的源文件内容的查找更新后,将所述每个源文件中的所有源文件内容对应替换为所述中间文件中的文件内容。After the search and update of the source file content of the last line of each source file is completed, all the source file content in each source file is correspondingly replaced with the file content in the intermediate file.

进一步地,处理器调用存储器中存储的程序代码,还可以用于执行以下操作:Furthermore, the processor calls the program code stored in the memory, which can also be used to perform the following operations:

将每个源文件中的所有源文件内容逐行依次对应替换为所述中间文件中的文件内容。All source file content in each source file is replaced line by line with the file content in the intermediate file.

进一步地,处理器调用存储器中存储的程序代码,在所述将所述每个源文件中的所有源文件内容对应替换为所述中间文件中的文件内容后,还可以用于执行以下操作:删除所述中间文件。Further, the processor invokes the program code stored in the memory, and after the corresponding replacement of all source file contents in each source file with the file contents in the intermediate file, it can also be used to perform the following operations: Delete said intermediate file.

进一步地,处理器调用存储器中存储的程序代码,还可以用于执行以下操作:Furthermore, the processor calls the program code stored in the memory, which can also be used to perform the following operations:

在接收对任一文件目录下的至少一个源文件的修改指令时,扫描所述任一文件目录,确定所述任一文件目录中是否包括至少一个子目录;When receiving a modification instruction for at least one source file under any file directory, scanning the any file directory to determine whether at least one subdirectory is included in the any file directory;

当确定所述任一文件目录中包括至少一个子目录时,根据所述修改指令循环访问所述至少一个子目录中的所有子目录,依次对每个子目录中包含的源文件进行逐行查找。When it is determined that any file directory includes at least one subdirectory, all subdirectories in the at least one subdirectory are cyclically visited according to the modification instruction, and the source files contained in each subdirectory are searched line by line in turn.

进一步地,处理器调用存储器中存储的程序代码,还可以用于执行以下操作:Furthermore, the processor calls the program code stored in the memory, which can also be used to perform the following operations:

当完成对当前子目录中的当前源文件的修改后,判断是否处理完所述当前子目录中包含的所有源文件;After completing the modification of the current source file in the current subdirectory, it is judged whether all the source files contained in the current subdirectory have been processed;

若未处理完所述当前子目录中包含的所有源文件,则对所述当前子目录中的下一个源文件中的源文件内容进行查找更新,否则判断是否处理完所述所有子目录;If all the source files contained in the current subdirectory have not been processed, then the source file content in the next source file in the current subdirectory is searched and updated, otherwise it is judged whether all the subdirectories have been processed;

若未处理完所述所有子目录,则对所述所有子目录中的下一子目录中包含的源文件进行逐行查找,直至处理完所述所有子目录,否则通过输出装置显示批量修改完成。If all the subdirectories have not been processed, the source files contained in the next subdirectory in all the subdirectories are searched line by line until all the subdirectories are processed, otherwise the batch modification is completed through the output device display .

在上述任一技术方案中,所述终端可以手机、平板电脑等移动终端。In any of the above technical solutions, the terminal may be a mobile terminal such as a mobile phone or a tablet computer.

以上技术方案,可以有效地提高批量修改文件内容的工作效率和准确度。The above technical solutions can effectively improve the work efficiency and accuracy of modifying file contents in batches.

附图说明Description of drawings

图1示出了本发明的第一实施例的文件内容的批量修改方法的流程示意图;FIG. 1 shows a schematic flow diagram of a method for batch modification of file content according to a first embodiment of the present invention;

图2示出了本发明的第二实施例的文件内容的批量修改方法的流程示意图;FIG. 2 shows a schematic flow diagram of a method for batch modification of file content according to a second embodiment of the present invention;

图3示出了本发明的第三实施例的文件内容的批量修改方法的流程示意图;FIG. 3 shows a schematic flow diagram of a method for batch modification of file content according to a third embodiment of the present invention;

图4示出了本发明的实施例的文件内容的批量修改操作的界面示意图;Fig. 4 shows the interface schematic diagram of the batch modification operation of the file content of the embodiment of the present invention;

图5示出了本发明的实施例的选取进行文件内容的批量修改操作的文件目录的示意图;5 shows a schematic diagram of a file directory selected for batch modification of file content according to an embodiment of the present invention;

图6示出了本发明的实施例的对选取的文件目录下的文件内容进行修改的设置界面示意图;FIG. 6 shows a schematic diagram of a setting interface for modifying file content in a selected file directory according to an embodiment of the present invention;

图7示出了本发明的第一实施例的文件内容的批量修改装置的示意框图;Fig. 7 shows the schematic block diagram of the device for batch modification of file content according to the first embodiment of the present invention;

图8示出了本发明的第二实施例的文件内容的批量修改装置的示意框图;FIG. 8 shows a schematic block diagram of a device for batch modification of file content according to a second embodiment of the present invention;

图9示出了本发明的第一实施例的终端的示意框图;Fig. 9 shows a schematic block diagram of a terminal according to a first embodiment of the present invention;

图10示出了本发明的第二实施例的终端的示意框图。Fig. 10 shows a schematic block diagram of a terminal according to the second embodiment of the present invention.

具体实施方式detailed description

为了能够更清楚地理解本发明的上述目的、特征和优点,下面结合附图和具体实施方式对本发明进行进一步的详细描述。需要说明的是,在不冲突的情况下,本申请的实施例及实施例中的特征可以相互组合。In order to understand the above-mentioned purpose, features and advantages of the present invention more clearly, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that, in the case of no conflict, the embodiments of the present application and the features in the embodiments can be combined with each other.

在下面的描述中阐述了很多具体细节以便于充分理解本发明,但是,本发明还可以采用其他不同于在此描述的其他方式来实施,因此,本发明的保护范围并不受下面公开的具体实施例的限制。In the following description, many specific details are set forth in order to fully understand the present invention. However, the present invention can also be implemented in other ways different from those described here. Therefore, the protection scope of the present invention is not limited by the specific details disclosed below. EXAMPLE LIMITATIONS.

下面结合图1和图2对本发明的一实施例的文件内容的批量修改方法进行详细说明。The method for modifying file content in batches according to an embodiment of the present invention will be described in detail below with reference to FIG. 1 and FIG. 2 .

如图1所示,根据本发明的实施例的文件内容的批量修改方法,具体包括以下流程步骤:As shown in Figure 1, the method for batch modification of file content according to the embodiment of the present invention specifically includes the following process steps:

步骤102,接收对任一文件目录下的至少一个源文件的修改指令。Step 102, receiving a modification instruction for at least one source file under any file directory.

步骤104,根据所述修改指令对所述至少一个源文件中的每个源文件进行逐行查找,检测每行的源文件内容中是否存在待修改内容。Step 104: Search each source file in the at least one source file line by line according to the modification instruction, and detect whether there is content to be modified in the source file content of each line.

步骤106,当在任一行的源文件内容中查找到所述待修改内容时,将所述待修改内容更新为替换内容,并将所述任一行的修改后的文件内容复制到中间文件的对应位置,否则将所述任一行的源文件内容复制到所述中间文件的对应位置。Step 106, when the content to be modified is found in the source file content of any line, update the content to be modified with replacement content, and copy the modified file content of any line to the corresponding position of the intermediate file , otherwise copy the source file content of any line to the corresponding position of the intermediate file.

步骤108,在完成对所述每个源文件的最后一行的源文件内容的查找更新后,将所述每个源文件中的所有源文件内容对应替换为所述中间文件中的文件内容。Step 108, after completing the searching and updating of the source file content in the last line of each source file, correspondingly replace all the source file content in each source file with the file content in the intermediate file.

在该实施例中,当确定需要进行文件内容的批量修改的文件目录时,对该文件目录下包含的所有源文件中的每个源文件执行自动逐行查找其源文件内容中是否存在待修改内容的,如果在查找每个源文件的每一行源文件内容时发现存在该待修改的内容,则在自动将其更新为替换内容后将该行修改后的文件内容复制到一中间文件的对应位置进行存储,而如果在查找每个源文件的每一行源文件内容时未发现该待修改的内容,则自动将该行的源文件内容复制到该中间文件的对应位置进行存储,如此直至查找更新完每个源文件的最后一行的源文件内容后,将该每个源文件中的内容对应替换为中间文件中存储的文件内容,从而完成对每个源文件的逐行查找更新,上述技术方案通过对任一文件目录下的所有源文件自动查找待修改内容并替换为用户需要的内容,可以有效地提高批量修改文件内容的工作效率和准确度。In this embodiment, when determining the file directory that needs to be modified in batches of file content, each source file in all source files contained in the file directory is automatically searched line by line for whether there is a file to be modified in the source file content. content, if it is found that there is content to be modified when searching for each line of source file content in each source file, copy the modified file content of this line to the corresponding intermediate file after it is automatically updated to replace the content location, and if the content to be modified is not found when searching for each line of source file content of each source file, the source file content of this line is automatically copied to the corresponding position of the intermediate file for storage, and so on until the search After updating the source file content of the last line of each source file, replace the content in each source file with the file content stored in the intermediate file, so as to complete the line-by-line search and update of each source file. The above technology The solution can effectively improve the work efficiency and accuracy of batch modification of file content by automatically searching for the content to be modified and replacing it with the content required by the user for all source files in any file directory.

进一步地,在上述实施例中,所述步骤108具体可以执行为:将每个源文件中的所有源文件内容逐行依次对应替换为所述中间文件中的文件内容。Further, in the above embodiment, the step 108 may specifically be performed as: replacing all source file contents in each source file line by line with the file content in the intermediate file.

在该实施例中,完成对每个源文件中的所有行的源文件内容的查找更新后,在将源文件中的所有源文件内容对应替换为临时建立的中间文件中存储的文件内容时,可以仍采用逐行进行替换的方式,以确保文件内容修改更新的准确度,从而提升用户体验。In this embodiment, after the search and update of the source file content of all lines in each source file is completed, when all the source file content in the source file is correspondingly replaced with the file content stored in the temporarily created intermediate file, The method of replacing line by line may still be used to ensure the accuracy of file content modification and update, thereby improving user experience.

进一步地,在上述任一实施例中,在所述步骤108之后,所述文件内容的批量修改方法还包括:删除所述中间文件。Further, in any of the above embodiments, after the step 108, the method for modifying the file content in batches further includes: deleting the intermediate file.

在该实施例中,为了避免临时建立的中间文件存在多个容易导致文件内容修改更新混乱的问题,在完成对每个源文件的文件内容的修改更新后即可以将该中间文件删除,同时节省其占用的存储空间。In this embodiment, in order to avoid multiple problems in the temporarily created intermediate file that may easily lead to confusion in the modification and update of the file content, the intermediate file can be deleted after the modification and update of the file content of each source file is completed, saving The storage space it occupies.

当然,在本发明的其他实施例中,也可以采用将中间文件中存储的文件内容清空的方式,以将该中间文件继续用于对下一个源文件的文件内容进行自动查找、修改更新的过程中,节省操作时间的同时也可以达到节省存储空间的目的。Of course, in other embodiments of the present invention, the method of clearing the file content stored in the intermediate file can also be adopted, so that the intermediate file can continue to be used for the process of automatically searching, modifying and updating the file content of the next source file In addition to saving operation time, it can also achieve the purpose of saving storage space.

进一步地,如图2所示,在上述任一实施例中,在所述步骤102中具体还可以包括步骤1021:扫描所述任一文件目录,确定所述任一文件目录中是否包括至少一个子目录。Further, as shown in FIG. 2, in any of the above-mentioned embodiments, step 102 may specifically include step 1021: scan any file directory, and determine whether any file directory includes at least one subdirectories.

进一步地,当确定所述任一文件目录中包括至少一个子目录时,所述步骤104具体还可以包括如下流程步骤:Further, when it is determined that any file directory includes at least one subdirectory, the step 104 may specifically include the following process steps:

步骤1041,根据所述修改指令循环访问所述至少一个子目录中的所有子目录,依次对每个子目录中包含的源文件进行逐行查找。Step 1041, iteratively visit all subdirectories in the at least one subdirectory according to the modifying instruction, and sequentially search for source files contained in each subdirectory line by line.

当确定需要进行文件内容的批量修改的文件目录,首先可以逐层扫描遍历该文件目录以确定其是否包含子目录,若包含则对该文件目录下的每个子目录进行逐层遍历直至查找到其中的源文件,即以下层包含源文件的子目录为处理单位,依次完成每个子目录中包含的源文件的修改,继而完成对文件目录下包含的所有源文件的源文件内容的修改,以避免出现文件遗漏未修改的情况。When determining the file directory that needs to be modified in batches, the file directory can be scanned and traversed layer by layer to determine whether it contains subdirectories. The source files of the source file, that is, the subdirectory containing the source file in the lower layer is the processing unit, and the modification of the source file contained in each subdirectory is completed in turn, and then the modification of the source file content of all the source files contained in the file directory is completed to avoid There is a situation where the file is missing and has not been modified.

步骤1042,当完成对当前子目录中的当前源文件的修改后,判断是否处理完所述当前子目录中包含的所有源文件。Step 1042, after the modification of the current source file in the current subdirectory is completed, it is judged whether all the source files contained in the current subdirectory have been processed.

步骤1043,若未处理完所述当前子目录中包含的所有源文件,则对所述当前子目录中的下一个源文件中的源文件内容进行查找更新,否则判断是否处理完所述所有子目录。Step 1043, if all the source files contained in the current subdirectory have not been processed, then search and update the source file content in the next source file in the current subdirectory, otherwise determine whether all the source files in the current subdirectory have been processed Table of contents.

步骤1044,若未处理完所述所有子目录,则对所述所有子目录中的下一子目录中包含的源文件进行逐行查找,直至处理完所述所有子目录,否则显示批量修改完成。Step 1044, if all the subdirectories have not been processed, then search for the source files contained in the next subdirectory in all the subdirectories line by line until all the subdirectories are processed, otherwise it will display that the batch modification is completed .

当完成一个子目录下的一个源文件的内容修改后,判断该子目录中包含的所有源文件是否均完成了内容修改,即确定该源文件是否为该子目录中的最后一个源文件,如果不是则继续对该子目录下的下一个源文件进行内容修改,否则判断是否处理完了文件目录下包含的所有子目录,即确定该子目录是否为文件目录下的最后一个子目录,若不是则继续处理下一个子目录中的源文件,直至处理完所有的源文件,否则若该子目录为文件目录下的最后一个子目录,则提示用户对该文件目录下的所有源文件的源文件内容的批量修改已完成,即通过递归查找搜索的方式完成文件内容的高效地批量修改,降低了出错率提高了工作效率。After completing the content modification of a source file in a subdirectory, judge whether all source files contained in the subdirectory have completed the content modification, that is, determine whether the source file is the last source file in the subdirectory, if If not, continue to modify the content of the next source file in the subdirectory, otherwise, judge whether all the subdirectories contained in the file directory have been processed, that is, determine whether the subdirectory is the last subdirectory in the file directory, if not, then Continue to process the source files in the next subdirectory until all source files are processed, otherwise, if the subdirectory is the last subdirectory under the file directory, the user will be prompted for the source file content of all source files under the file directory The batch modification of the file content has been completed, that is, the efficient batch modification of the file content is completed by means of recursive search and search, which reduces the error rate and improves work efficiency.

下面结合图3至图5对本发明的另一实施例的文件内容的批量修改方法进行详细说明。The method for modifying file content in batches according to another embodiment of the present invention will be described in detail below with reference to FIG. 3 to FIG. 5 .

如图3所示,根据本发明的实施例的文件内容的批量修改方法,具体包括以下流程步骤:As shown in Figure 3, the batch modification method of file content according to the embodiment of the present invention specifically includes the following process steps:

步骤302,配置目录以及设定需要更改的内容,举例来说,配置界面可以采用如图4所示的形式,而选择要进行文件内容批量修改的目录的操作界面如图5所示,如图所示选中的目录为“CPC207”文件目录,而设定的需要更改的内容(即替换内容)如图6所示。Step 302, configure the directory and set the content that needs to be changed. For example, the configuration interface can be in the form shown in Figure 4, and the operation interface for selecting the directory for batch modification of file content is shown in Figure 5, as shown in Figure 5. The selected directory shown is the "CPC207" file directory, and the set content that needs to be changed (that is, the content to be replaced) is shown in Figure 6.

步骤304,点击对应的“更改”按钮,如图6所示,在设定完需要更改的每一项内容后,对应地点击后面的“更改”按钮,实现对“CPC207”文件目录的所有文件中的相应内容的一键修改替换。Step 304, click the corresponding "Change" button, as shown in Figure 6, after setting each item that needs to be changed, click the "Change" button at the back correspondingly to implement all files in the "CPC207" file directory One-click modification and replacement of the corresponding content in .

步骤306,开始遍历文件夹,通过递归函数遍历其中的每一个文件,找到下一个文件,并打开文件。Step 306, start traversing the folder, traverse each file therein through a recursive function, find the next file, and open the file.

步骤308,找到下一行,通过逐行搜索的方式搜索到文件里我们想要更改的内容,即判断是否有需要更改的内容,若是执行步骤310,否则将这一行的内容复制到一个新建的中间文件中。Step 308, find the next line, and search for the content we want to change in the file through a line-by-line search, that is, determine whether there is any content that needs to be changed. in the file.

步骤310,更改为新内容,并将更改后的内容复制到中间文件中。Step 310, change to new content, and copy the changed content to the intermediate file.

步骤312,判断是不是最后一行,若是将中间文件的内容逐行复制到原文件中然后执行步骤314,否则执行步骤308;Step 312, judge whether it is the last line, if the content of the intermediate file is copied to the original file line by line and then perform step 314, otherwise perform step 308;

步骤314,判断是不是最后一个文件,若是则结束流程,否则返回执行步骤306,直至将该文件目录下所有文件均修改完。Step 314, judge whether it is the last file, if so, end the process, otherwise return to step 306, until all files in the file directory are modified.

进一步地,在将中间文件的内容复制到原文件中,可以选择将中间文件删除。Furthermore, when copying the content of the intermediate file to the original file, you can choose to delete the intermediate file.

综上,通过递归函数一个一个的搜索文件,当搜索到文件夹的时候,则进入文件夹继续搜索文件,当进入到最底层已经没有文件夹的时候则跳回到上一级文件夹,以此类推,最终遍历完目录下的所有文件。In summary, the recursive function is used to search for files one by one. When a folder is found, enter the folder to continue searching for files. By analogy, all files in the directory are finally traversed.

通过以上方案,在不增加硬件成本的前提下,可以自动找到我们需要更改的内容,并将之替换为我们需要的内容,以自动化的方式完成了一项枯燥冗杂的工作内容,之前耗时的工作量,现在只需点击一次按钮,就可以对成千上万个文件进行一次性更改,并且能够做到准确地对每一项内容进行正确的更改,确保万无一失,不仅提升了工作效率还可以降低工作出错率。Through the above scheme, without increasing the hardware cost, we can automatically find the content we need to change and replace it with the content we need, and complete a boring and complicated work content in an automated way. Workload, now you can make one-time changes to thousands of files with just one click of a button, and you can make the correct changes to each item accurately, ensuring nothing goes wrong, not only improving work efficiency but also Reduce work error rate.

下面结合图7和图8对本发明的实施例的文件内容的批量修改装置进行详细说明。The apparatus for modifying file content in batches according to the embodiment of the present invention will be described in detail below with reference to FIG. 7 and FIG. 8 .

如图7所示,根据本发明的实施例的文件内容的批量修改装置700,具体包括:输入模块702、遍历模块704、修改模块706和处理模块708。As shown in FIG. 7 , an apparatus 700 for modifying file content in batches according to an embodiment of the present invention specifically includes: an input module 702 , a traversal module 704 , a modification module 706 and a processing module 708 .

其中,所述输入模块702用于接收对任一文件目录下的至少一个源文件的修改指令;所述遍历模块704用于根据所述输入模块702接收的所述修改指令对所述至少一个源文件中的每个源文件进行逐行查找,检测每行的源文件内容中是否存在待修改内容;所述修改模块706用于当所述遍历模块704在任一行的源文件内容中查找到所述待修改内容时,将所述待修改内容更新为替换内容,并将所述任一行的修改后的文件内容复制到中间文件的对应位置,否则将所述任一行的源文件内容复制到所述中间文件的对应位置;所述处理模块708用于在完成对所述每个源文件的最后一行的源文件内容的查找更新后,将所述每个源文件中的所有源文件内容对应替换为所述中间文件中的文件内容。Wherein, the input module 702 is configured to receive a modification instruction for at least one source file under any file directory; the traversal module 704 is configured to modify the at least one source file according to the modification instruction received by the input module 702 Each source file in the file is searched line by line, and detects whether there is content to be modified in the source file content of each line; the modification module 706 is used to find the described When the content is to be modified, the content to be modified is updated to the replacement content, and the modified file content of any line is copied to the corresponding position of the intermediate file, otherwise the source file content of any line is copied to the The corresponding position of the intermediate file; the processing module 708 is configured to replace all source file contents in each source file with The file content in the intermediate file.

在该实施例中,当确定需要进行文件内容的批量修改的文件目录时,对该文件目录下包含的所有源文件中的每个源文件执行自动逐行查找其源文件内容中是否存在待修改内容的,如果在查找每个源文件的每一行源文件内容时发现存在该待修改的内容,则在自动将其更新为替换内容后将该行修改后的文件内容复制到一中间文件的对应位置进行存储,而如果在查找每个源文件的每一行源文件内容时未发现该待修改的内容,则自动将该行的源文件内容复制到该中间文件的对应位置进行存储,如此直至查找更新完每个源文件的最后一行的源文件内容后,将该每个源文件中的内容对应替换为中间文件中存储的文件内容,从而完成对每个源文件的逐行查找更新,上述技术方案通过对任一文件目录下的所有源文件自动查找待修改内容并替换为用户需要的内容,可以有效地提高批量修改文件内容的工作效率和准确度。In this embodiment, when determining the file directory that needs to be modified in batches of file content, each source file in all source files contained in the file directory is automatically searched line by line for whether there is a file to be modified in the source file content. content, if it is found that there is content to be modified when searching for each line of source file content in each source file, copy the modified file content of this line to the corresponding intermediate file after it is automatically updated to replace the content location, and if the content to be modified is not found when searching for each line of source file content of each source file, the source file content of this line is automatically copied to the corresponding position of the intermediate file for storage, and so on until the search After updating the source file content of the last line of each source file, replace the content in each source file with the file content stored in the intermediate file, so as to complete the line-by-line search and update of each source file. The above technology The solution can effectively improve the work efficiency and accuracy of batch modification of file content by automatically searching for the content to be modified and replacing it with the content required by the user for all source files in any file directory.

进一步地,在上述实施例中,所述处理模块708具体用于:将每个源文件中的所有源文件内容逐行依次对应替换为所述中间文件中的文件内容。Further, in the above embodiment, the processing module 708 is specifically configured to: replace all source file content in each source file line by line with the file content in the intermediate file.

在该实施例中,完成对每个源文件中的所有行的源文件内容的查找更新后,在将源文件中的所有源文件内容对应替换为临时建立的中间文件中存储的文件内容时,可以仍采用逐行进行替换的方式,以确保文件内容修改更新的准确度,从而提升用户体验。In this embodiment, after the search and update of the source file content of all lines in each source file is completed, when all the source file content in the source file is correspondingly replaced with the file content stored in the temporarily created intermediate file, The method of replacing line by line may still be used to ensure the accuracy of file content modification and update, thereby improving user experience.

进一步地,如图8所示,在上述任一实施例中,所述文件内容的批量修改装置700还包括:删除模块710,用于在所述处理模块708将所述每个源文件中的所有源文件内容对应替换为所述中间文件中的文件内容后,删除所述中间文件。Further, as shown in FIG. 8 , in any of the above-mentioned embodiments, the apparatus 700 for modifying file content in batches further includes: a deletion module 710, configured to delete each source file in the processing module 708 After the contents of all source files are correspondingly replaced with the file contents in the intermediate file, the intermediate file is deleted.

在该实施例中,为了避免临时建立的中间文件存在多个容易导致文件内容修改更新混乱的问题,在完成对每个源文件的文件内容的修改更新后即可以将该中间文件删除,同时节省其占用的存储空间。In this embodiment, in order to avoid multiple problems in the temporarily created intermediate file that may easily lead to confusion in the modification and update of the file content, the intermediate file can be deleted after the modification and update of the file content of each source file is completed, saving The storage space it occupies.

另一方面,也可以采用将中间文件中存储的文件内容清空的方式,以将该中间文件继续用于对下一个源文件的文件内容进行自动查找、修改更新的过程中,节省操作时间的同时也可以达到节省存储空间的目的。On the other hand, it is also possible to use the method of clearing the file content stored in the intermediate file, so as to continue to use the intermediate file in the process of automatically searching, modifying and updating the file content of the next source file, saving operation time and at the same time It can also achieve the purpose of saving storage space.

进一步地,如图8所示,在上述任一实施例中,所述输入模块702包括:遍历子模块7022,用于扫描所述任一文件目录,确定所述任一文件目录中是否包括至少一个子目录;以及所述遍历模块704具体还用于:当所述遍历子模块7022确定所述任一文件目录中包括至少一个子目录时,根据所述修改指令循环访问所述至少一个子目录中的所有子目录,依次对每个子目录中包含的源文件进行逐行查找。Further, as shown in FIG. 8, in any of the above-mentioned embodiments, the input module 702 includes: a traversal submodule 7022, configured to scan any file directory and determine whether any file directory includes at least A subdirectory; and the traversal module 704 is specifically further configured to: when the traversal submodule 7022 determines that any file directory includes at least one subdirectory, iterate through the at least one subdirectory according to the modification instruction All subdirectories in , and search the source files contained in each subdirectory line by line.

在该实施例中,当确定需要进行文件内容的批量修改的文件目录,首先可以逐层扫描遍历该文件目录以确定其是否包含子目录,若包含则对该文件目录下的每个子目录进行逐层遍历直至查找到其中的源文件,即以下层包含源文件的子目录为处理单位,依次完成每个子目录中包含的源文件的修改,继而完成对文件目录下包含的所有源文件的源文件内容的修改,以避免出现文件遗漏未修改的情况。In this embodiment, when determining the file directory that needs to be modified in batches, the file directory can first be scanned and traversed layer by layer to determine whether it contains subdirectories. Layer traversal until the source files in it are found, that is, the subdirectories containing source files in the lower layer are used as the processing unit, and the source files contained in each subdirectory are modified in turn, and then the source files of all source files contained in the file directory are completed. Modify the content to avoid the situation that the file is missing and not modified.

进一步地,如图8所示,在上述任一实施例中,所述文件内容的批量修改装置700还包括:判断模块712和控制模块714。Further, as shown in FIG. 8 , in any of the above embodiments, the apparatus 700 for modifying file content in batches further includes: a judgment module 712 and a control module 714 .

其中,所述判断模块712用于当完成对当前子目录中的当前源文件的修改后,判断是否处理完所述当前子目录中包含的所有源文件;所述控制模块714用于当所述判断模块712判定未处理完所述当前子目录中包含的所有源文件,则控制对所述当前子目录中的下一个源文件中的源文件内容进行查找更新,否则控制所述判断模块712判断是否处理完所述所有子目录;以及所述控制模块714还用于:用当所述判断模块712判定未处理完所述所有子目录,则控制对所述所有子目录中的下一子目录中包含的源文件进行逐行查找,直至处理完所述所有子目录,否则控制显示批量修改完成。Wherein, the judging module 712 is used for judging whether all the source files contained in the current subdirectory have been processed after the modification of the current source file in the current subdirectory is completed; the control module 714 is used for when the Judging module 712 determines that all source files contained in the current subdirectory have not been processed, then controls to search and update the source file content in the next source file in the current subdirectory, otherwise controls the judging module 712 to judge Whether all subdirectories have been processed; and the control module 714 is also used for: when the judging module 712 determines that all subdirectories have not been processed, then control the next subdirectory in all subdirectories The source files contained in are searched line by line until all the subdirectories are processed, otherwise the control displays that the batch modification is completed.

在该实施例中,当完成一个子目录下的一个源文件的内容修改后,判断该子目录中包含的所有源文件是否均完成了内容修改,即确定该源文件是否为该子目录中的最后一个源文件,如果不是则继续对该子目录下的下一个源文件进行内容修改,否则判断是否处理完了文件目录下包含的所有子目录,即确定该子目录是否为文件目录下的最后一个子目录,若不是则继续处理下一个子目录中的源文件,直至处理完所有的源文件,否则若该子目录为文件目录下的最后一个子目录,则提示用户对该文件目录下的所有源文件的源文件内容的批量修改已完成,即通过递归查找搜索的方式完成文件内容的高效地批量修改,降低了出错率提高了工作效率。In this embodiment, after the content modification of a source file in a subdirectory is completed, it is judged whether all source files contained in the subdirectory have completed the content modification, that is, it is determined whether the source file is a source file in the subdirectory. The last source file, if not, continue to modify the content of the next source file in the subdirectory, otherwise judge whether all the subdirectories contained in the file directory have been processed, that is, determine whether the subdirectory is the last one in the file directory subdirectory, if not, continue to process the source files in the next subdirectory until all the source files are processed, otherwise, if the subdirectory is the last subdirectory under the file directory, prompt the user for all the source files under the file directory The batch modification of the source file content of the source file has been completed, that is, the efficient batch modification of the file content is completed by means of recursive search and search, which reduces the error rate and improves work efficiency.

图9示出了本发明的第一实施例的终端的示意框图。Fig. 9 shows a schematic block diagram of a terminal according to the first embodiment of the present invention.

如图9所示,根据本发明的第一实施例的终端900,包括如上实施例中任一项所述的文件内容的批量修改装置700,因此,该终端900具有该文件内容的批量修改装置700所有的有益效果,在此不再赘述。As shown in Figure 9, the terminal 900 according to the first embodiment of the present invention includes the batch modification device 700 of the file content described in any one of the above embodiments, therefore, the terminal 900 has the batch modification device of the file content All beneficial effects of 700 will not be repeated here.

图10示出了本发明的第二个实施例的终端的示意框图。Fig. 10 shows a schematic block diagram of a terminal according to the second embodiment of the present invention.

如图10所示,根据本发明的第二个实施例的终端,包括:处理器1、输入装置2、输出装置3和存储器5。在本发明的一些实施例中,处理器1、输入装置2、输出装置3和存储器5可以通过总线4或其他方式连接,图10中以通过总线4连接为例。As shown in FIG. 10 , the terminal according to the second embodiment of the present invention includes: a processor 1 , an input device 2 , an output device 3 and a memory 5 . In some embodiments of the present invention, the processor 1 , the input device 2 , the output device 3 and the memory 5 may be connected through the bus 4 or other methods, and the connection through the bus 4 is taken as an example in FIG. 10 .

其中,存储器5用于存储一组程序代码,处理器1调用存储器5中存储的程序代码,用于执行以下操作:Wherein, the memory 5 is used to store a set of program codes, and the processor 1 invokes the program codes stored in the memory 5 to perform the following operations:

通过输入装置2接收对任一文件目录下的至少一个源文件的修改指令;Receive a modification instruction to at least one source file under any file directory through the input device 2;

根据所述修改指令对所述至少一个源文件中的每个源文件进行逐行查找,检测每行的源文件内容中是否存在待修改内容;Search each source file in the at least one source file line by line according to the modification instruction, and detect whether there is content to be modified in the source file content of each line;

当在任一行的源文件内容中查找到所述待修改内容时,将所述待修改内容更新为替换内容,并将所述任一行的修改后的文件内容复制到中间文件的对应位置,否则将所述任一行的源文件内容复制到所述中间文件的对应位置;When the content to be modified is found in the source file content of any row, the content to be modified is updated to replace the content, and the modified file content of any row is copied to the corresponding position of the intermediate file, otherwise the The source file content of any line is copied to the corresponding position of the intermediate file;

在完成对所述每个源文件的最后一行的源文件内容的查找更新后,将所述每个源文件中的所有源文件内容对应替换为所述中间文件中的文件内容。After the search and update of the source file content of the last line of each source file is completed, all the source file content in each source file is correspondingly replaced with the file content in the intermediate file.

作为一种可选的实施方式,处理器1调用存储器5中存储的程序代码,还可以用于执行以下操作:As an optional implementation manner, the processor 1 invokes the program code stored in the memory 5, and may also be used to perform the following operations:

将每个源文件中的所有源文件内容逐行依次对应替换为所述中间文件中的文件内容。All source file content in each source file is replaced line by line with the file content in the intermediate file.

作为一种可选的实施方式,处理器1调用存储器5中存储的程序代码,在所述将所述每个源文件中的所有源文件内容对应替换为所述中间文件中的文件内容后,还可以用于执行以下操作:删除所述中间文件。As an optional implementation manner, the processor 1 invokes the program code stored in the memory 5, and after the corresponding replacement of all source file contents in each source file with the file contents in the intermediate file, Can also be used to: delete said intermediate file.

作为一种可选的实施方式,处理器1调用存储器5中存储的程序代码,还可以用于执行以下操作:As an optional implementation manner, the processor 1 invokes the program code stored in the memory 5, and may also be used to perform the following operations:

在接收对任一文件目录下的至少一个源文件的修改指令时,扫描所述任一文件目录,确定所述任一文件目录中是否包括至少一个子目录;When receiving a modification instruction for at least one source file under any file directory, scanning the any file directory to determine whether at least one subdirectory is included in the any file directory;

当确定所述任一文件目录中包括至少一个子目录时,根据所述修改指令循环访问所述至少一个子目录中的所有子目录,依次对每个子目录中包含的源文件进行逐行查找。When it is determined that any file directory includes at least one subdirectory, all subdirectories in the at least one subdirectory are cyclically visited according to the modification instruction, and the source files contained in each subdirectory are searched line by line in turn.

作为一种可选的实施方式,处理器1调用存储器5中存储的程序代码,还可以用于执行以下操作:As an optional implementation manner, the processor 1 invokes the program code stored in the memory 5, and may also be used to perform the following operations:

当完成对当前子目录中的当前源文件的修改后,判断是否处理完所述当前子目录中包含的所有源文件;After completing the modification of the current source file in the current subdirectory, it is judged whether all the source files contained in the current subdirectory have been processed;

若未处理完所述当前子目录中包含的所有源文件,则对所述当前子目录中的下一个源文件中的源文件内容进行查找更新,否则判断是否处理完所述所有子目录;If all the source files contained in the current subdirectory have not been processed, then the source file content in the next source file in the current subdirectory is searched and updated, otherwise it is judged whether all the subdirectories have been processed;

若未处理完所述所有子目录,则对所述所有子目录中的下一子目录中包含的源文件进行逐行查找,直至处理完所述所有子目录,否则通过输出装置3显示批量修改完成。If all subdirectories have not been processed, the source files contained in the next subdirectory in all subdirectories are searched line by line until all subdirectories are processed, otherwise batch modification is displayed by output device 3 Finish.

本发明实施例的方法中的步骤可以根据实际需要进行顺序调整、合并和删减。The steps in the methods of the embodiments of the present invention can be adjusted, combined and deleted according to actual needs.

本发明实施例的文件内容的批量修改装置和终端中的单元可以根据实际需要进行合并、划分和删减。The device for modifying file content in batches in the embodiment of the present invention and the units in the terminal can be merged, divided and deleted according to actual needs.

本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质包括只读存储器(Read-Only Memory,ROM)、随机存储器(Random Access Memory,RAM)、可编程只读存储器(Programmable Read-only Memory,PROM)、可擦除可编程只读存储器(Erasable Programmable Read Only Memory,EPROM)、一次可编程只读存储器(One-time Programmable Read-Only Memory,OTPROM)、电子抹除式可复写只读存储器(Electrically-Erasable Programmable Read-Only Memory,EEPROM)、只读光盘(CompactDisc Read-Only Memory,CD-ROM)或其他光盘存储器、磁盘存储器、磁带存储器、或者能够用于携带或存储数据的计算机可读的任何其他介质。Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above-mentioned embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium includes read-only Memory (Read-Only Memory, ROM), Random Access Memory (Random Access Memory, RAM), Programmable Read-Only Memory (Programmable Read-only Memory, PROM), Erasable Programmable Read-Only Memory (Erasable Programmable Read Only Memory, EPROM), One-time Programmable Read-Only Memory (OTPROM), Electronically Erasable Programmable Read-Only Memory (EEPROM), Compact Disc Read-Only Memory (CompactDisc Read -Only Memory, CD-ROM) or other optical disk storage, magnetic disk storage, tape storage, or any other computer-readable medium that can be used to carry or store data.

进一步地,上述终端可以手机、平板电脑等移动终端。Further, the above-mentioned terminal may be a mobile terminal such as a mobile phone or a tablet computer.

以上结合附图详细说明了本发明的技术方案,可以有效地提高批量修改文件内容的工作效率和准确度。The technical solution of the present invention has been described in detail above in conjunction with the accompanying drawings, which can effectively improve the work efficiency and accuracy of modifying file content in batches.

以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.

Claims (6)

1. A method for modifying file contents in batches is characterized by comprising the following steps:
receiving a modification instruction of at least one source file in any file directory;
searching each source file in the at least one source file line by line according to the modification instruction, and detecting whether contents to be modified exist in the source file contents of each line;
when the content to be modified is found in the source file content of any line, the content to be modified is updated to be replacement content, the modified file content of any line is copied to the corresponding position of an intermediate file, otherwise, the source file content of any line is copied to the corresponding position of the intermediate file;
after the searching and updating of the source file content of the last line of each source file are completed, correspondingly replacing all the source file contents in each source file with the file contents in the intermediate file;
the step of replacing all source file contents in each source file with file contents in the intermediate file correspondingly comprises:
all source file contents in each source file are sequentially and correspondingly replaced by file contents in the intermediate file line by line;
the step of receiving a modification instruction for at least one source file in any file directory further includes: scanning any file directory, and determining whether at least one subdirectory is included in any file directory; and
when it is determined that any file directory includes at least one subdirectory, the step of searching each source file of the at least one source file line by line according to the modification instruction specifically includes: and circularly accessing all the subdirectories in the at least one subdirectory according to the modification instruction, and sequentially searching source files contained in each subdirectory line by line.
2. The method for bulk modification of file content according to claim 1,
after the corresponding replacement of all the source file contents in each source file with the file contents in the intermediate file, the batch modification method of the file contents further includes: and deleting the intermediate file.
3. The method for batch modification of file contents according to claim 1, further comprising:
after finishing modifying the current source file in the current subdirectory, judging whether all the source files contained in the current subdirectory are processed;
if all source files contained in the current subdirectory are not processed, searching and updating the source file content in the next source file in the current subdirectory, otherwise, judging whether all the subdirectories are processed;
and if all the subdirectories are not processed, searching source files contained in the next subdirectory in all the subdirectories line by line until all the subdirectories are processed, otherwise, displaying that the batch modification is finished.
4. An apparatus for batch modification of file contents, comprising:
the input module is used for receiving a modification instruction of at least one source file in any file directory;
the traversal module is used for searching each source file in the at least one source file line by line according to the modification instruction received by the input module and detecting whether the source file content of each line has content to be modified;
the modification module is used for updating the content to be modified into the replacement content when the traversal module finds the content to be modified in the source file content of any line, copying the modified file content of any line to the corresponding position of the intermediate file, and otherwise copying the source file content of any line to the corresponding position of the intermediate file;
the processing module is used for correspondingly replacing all source file contents in each source file with file contents in the intermediate file after the searching and updating of the source file contents in the last line of each source file are completed;
the processing module is specifically configured to:
all source file contents in each source file are sequentially and correspondingly replaced by file contents in the intermediate file line by line;
the input module includes: the traversal submodule is used for scanning any file directory and determining whether the any file directory comprises at least one subdirectory; and
the traversal module is further specifically configured to: when the traversal submodule determines that any file directory comprises at least one subdirectory, circularly accessing all subdirectories in the at least one subdirectory according to the modification instruction, and sequentially searching source files contained in each subdirectory line by line.
5. The apparatus for batch modification of file contents according to claim 4, further comprising:
and the deleting module is used for deleting the intermediate file after the processing module correspondingly replaces all the source file contents in each source file with the file contents in the intermediate file.
6. The apparatus for batch modification of file contents according to claim 4, further comprising:
the judging module is used for judging whether all source files contained in the current subdirectory are processed or not after the modification of the current source file in the current subdirectory is finished;
the control module is used for controlling the searching and updating of the content of the source file in the next source file in the current subdirectory when the judging module judges that all the source files in the current subdirectory are not processed, or controlling the judging module to judge whether all the subdirectories are processed; and
the control module is further configured to: and when the judging module judges that all the subdirectories are not processed completely, controlling to search source files contained in the next subdirectory in all the subdirectories line by line until all the subdirectories are processed completely, and otherwise, controlling to display that the batch modification is completed.
CN201710071896.6A 2017-02-09 2017-02-09 Batch modification method and device for file contents Active CN106933967B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710071896.6A CN106933967B (en) 2017-02-09 2017-02-09 Batch modification method and device for file contents

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710071896.6A CN106933967B (en) 2017-02-09 2017-02-09 Batch modification method and device for file contents

Publications (2)

Publication Number Publication Date
CN106933967A CN106933967A (en) 2017-07-07
CN106933967B true CN106933967B (en) 2022-12-20

Family

ID=59423951

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710071896.6A Active CN106933967B (en) 2017-02-09 2017-02-09 Batch modification method and device for file contents

Country Status (1)

Country Link
CN (1) CN106933967B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107679081B (en) * 2017-08-30 2020-06-30 平安科技(深圳)有限公司 Information modification method and device, computer equipment and computer readable storage medium
CN107729002A (en) * 2017-09-27 2018-02-23 上海斐讯数据通信技术有限公司 Source file compression set
CN109688176B (en) * 2017-10-18 2022-01-11 腾讯科技(深圳)有限公司 File synchronization method, terminal, network device and storage medium
CN108776569B (en) * 2018-04-20 2021-10-15 贵阳朗玛信息技术股份有限公司 Method and device for modifying compiling option control file
CN108647317B (en) * 2018-05-10 2021-05-07 东软集团股份有限公司 Incremental file generation method and device, storage medium and electronic equipment
CN109242417A (en) * 2018-08-20 2019-01-18 中国平安财产保险股份有限公司 Declaration form batch modification method, apparatus, computer equipment and storage medium
CN109597796A (en) * 2018-10-23 2019-04-09 平安科技(深圳)有限公司 File content amending method, device and computer readable storage medium
CN111008006A (en) * 2019-10-18 2020-04-14 宇龙计算机通信科技(深圳)有限公司 RFC file modification method and device, storage medium and terminal

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101599066A (en) * 2008-06-03 2009-12-09 鸿富锦精密工业(深圳)有限公司 Document batch operation management system and method
CN103778268A (en) * 2012-10-24 2014-05-07 鸿富锦精密工业(深圳)有限公司 Automatic classifying method and system for documents

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2409251A4 (en) * 2009-03-20 2015-03-18 Ad Vantage Networks Llc METHODS AND SYSTEMS FOR SEARCHING, SELECTING AND DISPLAYING CONTENT

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101599066A (en) * 2008-06-03 2009-12-09 鸿富锦精密工业(深圳)有限公司 Document batch operation management system and method
CN103778268A (en) * 2012-10-24 2014-05-07 鸿富锦精密工业(深圳)有限公司 Automatic classifying method and system for documents

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
文件王朝 一统天下 文件批量替换技巧;苏胜;《电脑爱好者》;20060115(第02期);全文 *

Also Published As

Publication number Publication date
CN106933967A (en) 2017-07-07

Similar Documents

Publication Publication Date Title
CN106933967B (en) Batch modification method and device for file contents
JP6174825B2 (en) Management system for creating services
JPWO2006098031A1 (en) Keyword management device
WO2018011959A1 (en) Management system and management method
CN110297808A (en) File modification method, apparatus, computer equipment and the storage medium of container application
KR101986476B1 (en) Program writing device
US20080288560A1 (en) Storage management method using data migration
KR100764651B1 (en) Method and apparatus for running an application in a portable terminal
CN105511904B (en) A kind of method and device automatically updating quick window
CN117873556A (en) Version management method, system, device, equipment and medium for chip verification
CN116136846B (en) A management method, device and storage system for unstructured object data
CN111045991B (en) Implementation method for quickly opening file based on command line mode
CN116167882A (en) Conditional expression dynamic configuration method, accounting condition calculation method and accounting condition calculation device
CN115237387A (en) Rapid development method and system for digital twin application
JP2003015922A (en) Data processing method and apparatus and storage medium
US20220103508A1 (en) Information processing apparatus and information processing method
JP2015111429A (en) Alteration management support apparatus, alteration management support method, and alteration management support program
CN110989876A (en) Application program adaptation method, mobile terminal and storage medium
JP2015095035A (en) Parameter setting support system, parameter setting support method, and parameter setting support program
US9753640B2 (en) Communication apparatus, control apparatus, method of controlling input unit, and medium
KR101659546B1 (en) User apparatus for displaying item using combobox and item display method
JP2001291112A (en) Graphic editing apparatus, graphic editing method, and recording medium storing program therefor
CN109062579B (en) Control method and control device for quickly uninstalling application program
JP2009151727A (en) Document processing system
JP2982370B2 (en) Operating condition setting method of information processing system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20250616

Address after: 361000 Fujian Province Xiamen City Xiamen Torch High-tech Industrial Development Zone Software Park Phase III, No. 1124 Beidao Road, Jimei District, Room 1303-9

Patentee after: Xiamen Hanyang Chuangyi Cultural Media Co.,Ltd.

Country or region after: China

Address before: 518057 Guangdong Province Nanshan High-tech Industrial Park North District Kupai Information Port, 2 Buildings, 2 Floors

Patentee before: YULONG COMPUTER TELECOMMUNICATION SCIENTIFIC (SHENZHEN) Co.,Ltd.

Country or region before: China

TR01 Transfer of patent right