powershell - Adding an auto-incrementing number to a file name string -


i powershell script modify name of file increment number every time.

this file name: abc-0.2.0.1-snapshot-barista.zip. want write syntax increment every time mentioned below:

 abc-0.2.0.2-snapshot-barista.zip abc-0.2.0.3-snapshot-barista.zip abc-0.2.0.4-snapshot-barista.zip abc-0.2.0.5-snapshot-barista.zip abc-0.2.0.6-snapshot-barista.zip abc-0.2.0.7-snapshot-barista.zip abc-0.2.0.8-snapshot-barista.zip abc-0.2.0.9-snapshot-barista.zip abc-0.2.0.10-snapshot-barista.zip abc-0.2.0.11-snapshot-barista.zip 

and on …

use regular expression replacement callback function:

$name = 'abc-0.2.0.4-snapshot-barista.zip'  [regex]$re = '(.*?\.)(\d+)(-snapshot-.*\.zip)' $cb = {     $a, $b, $c = $args[0].groups[1..3].value     '{0}{1}{2}' -f $a, ([int]$b+1), $c }  $re.replace($name, $cb) 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -