Powershell 批量重命名

先建立幾個用於測試的文件

$Directory = "C:\Test"
For($i=0;$i -le 10; ++$i) {
Set-Content -Path $("$Directory\Test($i).txt") -value $i 
}

建立結果以下圖:
Powershell 批量重命名html

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

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

結果以下圖:
Powershell 批量重命名shell

學習連接:

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

相關文章
相關標籤/搜索