Bat reads the path information table of a type of files in a folder.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.