$files = Get-Location | Get-ChildItem
$current = Get-Location
Write-Output $current.Path
for ($i = 0; $i -lt $files.Length; $i++) {
$file = $files[$i]
if ($file.FullName.EndsWith(".png")) {
Write-Output "-------------------"
$array = $file.Name.Replace("等级勋章/", "").Split("@")
$b = $array[1].Replace("2x(", "").Replace(").png", "")
$num = 0
if (-Not($b.Equals("2x.png"))) {
$num = $b -as [int]
}
$level = ($array[0].Split("-")[0] -as [int]) + $num
$resultName = $file.Directory.FullName+"\"+("level_"+$level+".png")
Rename-Item -Path $file.FullName -NewName $resultName
Write-Output ("Rename "+$file.FullName+" to " +$resultName)
# Write-Output $array[0]
# Write-Output $num
}
}
#code
标签:改名,批量,Write,num,file,Output,array,PowerShell,png
From: https://www.cnblogs.com/xunevermore/p/17794872.html