需要有关 Windows 批处理脚本的帮助,该脚本应根据文件名的一部分设置 var 的 val
这不是作业 - 谁会有关于批处理脚本的作业? 我需要自动化一些东西。目前有一个硬编码的批处理脚本,需要每天运行来获取系统,并且它需要以动态方式工作。它所需要的输入只是一个内部版本号,该内部版本号可以从位于...(例如 C:\DumpLocation\
)的文件名中推断出来。我不擅长批处理脚本,正在寻找批处理忍者。如果由我决定,我会自己用 Python 编写代码,但我不能指望其他人为此安装它。 PowerShell 也并非在每台 Windows 计算机上都可用,因此批处理脚本是最低公分母。
这是我希望脚本执行的操作:
dirToLookAt = 'C:\DumpLocation\'
# In that location there should be a single file named
# Custom_SomethingBuild34567Client_12345.zip
# I want to extract the build number into a variable to this effect:
buildNumber = '34567'
# strings which surround the build number are fixed.
# If there is more than one zip file with a build number in it,
# I need to print a warning and pick the largest one.
# I can do the rest.
以下内容也应该有所帮助:
http://www.computing。 net/answers/programming/batch-string-substitution/12097.html
如果您有疑问,请告诉我。
This is not a homework - who would have homework on batch scripting?
I need to automate something. Currently there is a hard-coded batch script meant to be run daily to get systems, and it needs to work in a dynamic fashion. All it needs as an input is a build number, which can be deduced from the name of the file located at ... say C:\DumpLocation\
. I am not good at batch scripting, and looking for a batch Ninja. If it was up to me, I would code this up in Python myself, but I cannot expect others to install it just for this. PowerShell is also not available on every Windows computer, so batch script is the lowest common denominator.
This should help:
http://www.techsupportforum.com/microsoft-support/windows-xp-support/54848-set-variable-based-output-seach-string-batch.html
Here is what I want the script to do:
dirToLookAt = 'C:\DumpLocation\'
# In that location there should be a single file named
# Custom_SomethingBuild34567Client_12345.zip
# I want to extract the build number into a variable to this effect:
buildNumber = '34567'
# strings which surround the build number are fixed.
# If there is more than one zip file with a build number in it,
# I need to print a warning and pick the largest one.
# I can do the rest.
The following should help as well:
http://www.computing.net/answers/programming/batch-string-substitution/12097.html
Please let me know if you have questions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设
Custom_SomethingBuild
和Client_12345.zip
是常量,这应该可以解决问题:Assuming that
Custom_SomethingBuild
andClient_12345.zip
are constants, this should do the trick: