如果文件个数超过99可以把12和20行的d2改d3 d4 等等- <# :
- @echo off
- set "args=%*"
- powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0' |Out-String|Invoke-Expression"
- pause
- #>
- $n=1
- $a=read-host "请输入文本"
- if ($a -eq ""){
- $env:args.split(" ")|%{
- $file=[System.IO.FileInfo]($_)
- $newname="{0}{1:d2}{2}" -f $file.basename,$n , $file.Extension
- ren $file $newname
- $n+=1
- }
- }
- else {
- $env:args.split(" ")|%{
- $file=[System.IO.FileInfo]($_)
- $newname="{0}{1:d2}{2}" -f $a,$n , $file.Extension
- ren $file $newname
- $n+=1
- }
- }
复制代码
|