如何在批处理文件中引用随机数(%random%)
我遇到过一个相当奇怪的情况。
我在批处理文件中生成了一个随机数,它基本上创建了一个文件,
例如> %random%%random%.txt
不过,如果我要在脚本的稍后阶段引用这个随机生成的文件,我将如何实现这一点? (请记住,执行 *.txt 之类的操作是行不通的,因为有数百个文本文件)。
I have come across a rather odd situation.
I have generated a a random number in a batch file, which basically creates a file
e.g. > %random%%random%.txt
Although, if I was to refer to this randomly generated file at a later stage in the script how would I accomplish this? (Baring in mind doing something like *.txt would not work, as there are hundreds of text files).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需将生成的值保存在变量中即可。
一旦使用
set
进行分配,%x%
和%filename%
将不会再次更改。You simply save the generated value in a variable.
Once they have been assigned using
set
,%x%
and%filename%
will not change again.