Problem Background:A large project always contains many bat, Py, or sh files. to search for and count these files to observe the workflow of the entire project, a script is required for these files.
The path information table of the adhesive file.
Preliminary ideas:Use for: For/R. % F in ("*. % 1") Do echo % ~ F recursion of the current directory to obtain the path information table of the file of parameter 1
Gradually improved:Use for: For/R. % F in ("*. % 1") Do echo % ~ F> input pathlist.txt to pathlist.txt.
Gradually improved:Use for: For/R. % F in ("*. % 1") Do echo % ~ F> input pathlist.txt to pathlist.txt and name the file filenum. bat;
Create a new BAT file, filecount. bat, and calculate the path information of the BAT file. The script code is. \ filenum. Bat bat> NUL. In this way, the redundant output of the call is not displayed.
Gradually improved:Package these two files into a folder named filecount to enhance readability and function cohesion. Modify filenum. BAT: For/R .. \ % F in ("*. % 1 ") Do echo % ~ F> pathlist.txt.
In this way, all the BAT file path information in the external folder of the packaged folder is listed, and the generated path information table is still in filecount, reflecting the function cohesion.
Gradually improved:Added support for one-time calling of multiple types of files. Modify filecount. BAT to count the number of H, CPP, C, and HPP files. The code is call. \ filenum. Bat h cpp c hpp> NUL;
Modify filenum at the same time. BAT to support multiple file type parameters: For % I in (% *) Do (for/R .. \ % F in (*. % I) Do echo % ~ F> bat.txt ).
To be improved:Hosts file.
You need to consider how to make the traversal command in filenum. BAT not include the traversal of the filecount folder, but must include the traversal of the filecount folder in other paths, otherwise it is a bug.
To be improved:You can change the name of pathlist.txt to increase the generation time and the complete path of the detected folder.
We look forward to a better solution.