Loop string rename

前端 未结 1 1870
执笔经年
执笔经年 2021-01-28 13:15

I\'m running a script that takes a screenshot and saves to file. I\'m a novice and having trouble integrating mouse events so for now I\'m going to complete part of my task manu

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-28 14:07

    You can do something like this:

    $i = 0
    do {
      $i++
      $File = "C:\Users\mydirectory\image$i.bmp"
    } until (-not (Test-Path -LiteralPath $File) -or $i -ge 500)
    

    That increments the number ($i) until a non-existing filename is found or $i reaches 500.

    0 讨论(0)
提交回复
热议问题