在目录名称中嵌入计数器循环的值

时间:2015-03-12 14:42:55

标签: autoit

我正在尝试将AutoIt计数器循环的当前值嵌入到目录名中。我正在运行1000次迭代分析,需要确保统计软件的输出不会覆盖自身。这是我的代码:

$counter = 0
Do
    FileCopy("C:\Users\Lambeezy\Documents\Folder\ReferentGroup.txt", "C:\Users\Lambeezy\Documents\DifferentFolder\"$counter")
    $counter = $counter + 1
Until $counter = 5

2 个答案:

答案 0 :(得分:1)

根据Documentation - Language Reference - Operators

  

&连接/连接两个字符串。

     

&=连接分配。

AutoIt allows串联到整数。使用For...To...Step...Next循环的示例:

Global Const $g_iMax     = 5
Global Const $g_sPathSrc = 'C:\Users\Lambeezy\Documents\Folder\ReferentGroup.txt'
Global Const $g_sPathDst = 'C:\Users\Lambeezy\Documents\DifferentFolder\'
Global       $g_sPathCur = ''

For $i1 = 1 To $g_iMax

    $g_sPathCur = $g_sPathDst & $i1

    FileCopy($g_sPathSrc, $g_sPathCur)

Next

或者可以使用StringFormat()

Global Const $g_iMax     = 5
Global Const $g_sPathSrc = 'C:\Users\Lambeezy\Documents\Folder\ReferentGroup.txt'
Global Const $g_sPathDst = 'C:\Users\Lambeezy\Documents\DifferentFolder\%s'
Global       $g_sPathCur = ''

For $i1 = 1 To $g_iMax

    $g_sPathCur = StringFormat($g_sPathDst, $i1)

    FileCopy($g_sPathSrc, $g_sPathCur)

Next

Related

答案 1 :(得分:0)

在此处的语言参考中对其进行了描述:https://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm

  

&连接/连接两个字符串。例如"one" & 10(等于" one10")

$counter = 0 
Do 
    FileCopy("C:\Users\Lambeezy\Documents\Folder\ReferentGroup.txt", "C:\Users\Lambeezy\Documents\DifferentFolder\" & $counter) 
    $counter = $counter + 1 
Until $counter = 5