How to convert string to integer in PowerShell

后端 未结 5 691
走了就别回头了
走了就别回头了 2020-12-29 19:36

I have a list of directories with numbers. I have to find the highest number and and increment it by 1 and create a new directory with that increment value. I am able to sor

5条回答
  •  清酒与你
    2020-12-29 20:01

    Use:

    $filelist = @(11, 1, 2)
    $filelist | sort @{expression={$_[0]}} | 
      % {$newName = [string]([int]$($_[0]) + 1)}
      New-Item $newName -ItemType Directory
    

提交回复
热议问题