DOS batch processing: Read configuration files, formats and programs, for example

Source: Internet
Author: User

Whether DOS batch processing can be performedProgramRead the configuration file, similar to the INI file?

I have found a feasible solution. Examples of programs and configuration files are as follows.

The purpose of this article is to record and prepare materials for future reference.

 

Configuration file:

 
# Configuration file, parsing configuration variables # One Line for each configuration file setting value # You can add a comment line with "#" # "for behavior # You can add a" # "comment # the path of the file can be an absolute path, it can also be a relative path. In Windows, the file path must use "/" instead of "\" to indicate the connector connection string osqlcnstr =-s127.0.0.1, 21433-e-H-1-n-B-M15-W 500366bcp.exe connection string bcpcnstr =-s127.0.0.1, 21433-T-cdbserver = (local) database = testdbuid = testuserpwd = testpwdinputdatadir =. \ datainputdatafile = contactinfo.txt dtslogfile = cvt_usrinfo.log ################################# ######################

 

 

Batch Processing Program:

 @ echo offset DEBUG = 0rem the configuration file uses" # "as the line. the row-end annotator REM configuration item cannot contain spaces or double quotation marks. Rem configuration values cannot contain double quotation marks. Rem removes empty rows and comment rows.. Note that the rows with spaces cannot be removed. Take % B and discard the % becho. Echo environment variable configuration as follows: For/F "EOL = # tokens = *" % A in (% ~ N0.txt) Do (REM echo. If % debug % = 1 echo debug 1: A = % A. B = % B. Rem remove the end comments of the line. Take % m and discard % Nfor/F "delims = # tokens = 1 *" % m in ("% ") do (if % debug % = 1 echo debug 2: M = % m. N = % N. rem resolution configuration to Remove empty lines. Take % x, % Y, discard % zfor/F "delims = tokens = 1, 2 *" % x in ("% m ") do (if % debug % = 1 echo debug 3: x = % x. y = % Y. if not "% Y" = "" (REM removes the white space character of the configuration item. For/F % K in ("% x") Do (REM removes the blank characters of the Configuration value. For/F "tokens = 1 *" % v in ("% Y") Do (if "% W" = "" (echo. % K. =. % v. set % K = % v) else (echo. % K. =. % v % W. set % K = % v % W) echo read configuration is complete. echo. 

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.