欢迎光临
我们一直在努力

Powershell 批量重命名

先创建几个用于测试的文件
$Directory = "C:\Test"
For($i=0;$i -le 10; ++$i) {
Set-Content -Path $("$Directory\Test($i).txt") -value $i 
}

创建结果如下图:

使用下面的命令把Test换成Mail

PS D:\> $Directory = "C:\Test"
PS D:\> Get-ChildItem $Directory | Rename-Item -NewName { $_.name -Replace "Test","Mail" }

结果如下图:

学习链接:

http://www.computerperformance.co.uk/powershell/powershell_replace.htm
http://www.pstips.net/bulk-renaming-files.html

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。