Board logo

标题: [文件操作] 批处理copy时如何带变量路径? [打印本页]

作者: hebebon    时间: 2011-2-19 20:48     标题: 批处理copy时如何带变量路径?

变量=1~10之间的随机数
copy c:\变量.jpg d:\aaa.jpg
求解
作者: CrLf    时间: 2011-2-19 21:02

  1. set /a n=%time:~-1%+1
  2. copy c:\%n%.jpg d:\aaa.jpg
复制代码

作者: hebebon    时间: 2011-2-19 22:08

原帖由 zm900612 于 2011-2-19 21:02 发表
set /a n=%time:~-1%+1
copy c:\%n%.jpg d:\aaa.jpg


好像两次取出的随机数重复率蛮高的
作者: CrLf    时间: 2011-2-19 22:23

哦,多次运行还是用set /a n=%random%%%10+1来获取随机数吧




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2