重命名测试.bat- @echo off
- powershell -Command "Set-Location -LiteralPath '%~dp0'; $n = 10001; ([System.IO.Directory]::GetFiles('.', '*.mp3')|Split-Path -Leaf|Select-String -Pattern '^(\d+)(.*)(\.mp3)$'|ForEach-Object {New-Object -TypeName psobject -Property @{id = [int]$_.Matches[0].Groups[1].Value; fileName = $_.Line; subName1 = $_.Matches[0].Groups[2].Value; subName2 = $_.Matches[0].Groups[3].Value}})|Sort-Object -Property id|ForEach-Object {Rename-Item -LiteralPath $_.fileName -NewName (([string]$n).Substring(1) + $_.subName1 + $_.subName2) -WhatIf; $n++}"
- pause
- exit /b
复制代码
|