网站建设资讯

NEWS

网站建设资讯

Powershell批量重命名

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

创建结果如下图:
Powershell 批量重命名

创新互联是一家专注于成都网站制作、网站建设与策划设计,卢龙网站建设哪家好?创新互联做网站,专注于网站建设十载,网设计领域的专业建站公司;建站业务涵盖:卢龙等地区。卢龙做网站价格咨询:18980820575

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

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

结果如下图:
Powershell 批量重命名

学习链接:

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


本文标题:Powershell批量重命名
网站地址:http://cdweb.net/article/jgjgos.html