小编Gha*_*ing的帖子

Is there a way to parse arguments into a batch script

I have found a very useful script here that will parse in arguments to a batch file and process them as follows:

BatchFile.btm /a /b:22 /longopt Parm1 Parm2 /quotedArg:"long quoted arg"
   - OPTION_a will equal 1.
   - OPTION_b will equal 22
   - OPTION_quotedArg will equal "long quoted arg"
   - OPTION_longopt will eqal 1.
   - PARAM_1 will equal Parm1
   - PARAM_2 will equal Parm2
   - PARAM_0 will be set to the number of parms, so 2 in this case
Run Code Online (Sandbox Code Playgroud)

However, this …

windows batch command-line

8
推荐指数
1
解决办法
1万
查看次数

如何在批处理文件中的字符串末尾附加动态数量的空格

我想将信息输出到日志文件中

01/08/2013 14:30 - Dynamic-Machine-Name    - Message starts
02/08/2013 07:12 - DynamicMachineName      - Log entry
02/08/2013 07:14 - Dynamic-PC-Name         - Information here
02/08/2013 08:01 - PC-Name                 - Execution continues
03/08/2013 09:00 - Dynamic-Name            - Message starts
03/08/2013 15:29 - Dynamic-Machine-Name    - Log information
03/08/2013 15:30 - Random-Machine-Name     - Message etc.
Run Code Online (Sandbox Code Playgroud)

但是为了在右侧对齐日志消息,我需要计算我已经完成的机器名称的长度,并从最大长度中减去它以获得一个数字空格。

我无法解决的是如何生成一个包含“x”个空格的字符串,或者如何将那些“x”个空格附加到机器名称的末尾?

string-manipulation concatenation batch-file

5
推荐指数
1
解决办法
7866
查看次数