PowerShell批量替换文件名

1、新建.ps1后缀文件

$Path = 'D:\plugin'

$Filter = '*.js'

$newtext = 'abcdef'

$oldtext = 'abc'

ls $Path -Include $Filter -Recurse | ForEach-Object{Rename-Item $_.FullName$_.FullName.Replace($oldtext,$newtext)}

说明:$Path代表文件路径、$Filter指的是文件类型、$oldtext代表被替换的字符、$newtext代表替换后的字符。

2、右键.ps1文件——选择使用 PowerShell运行——完成

猜你喜欢

转载自blog.csdn.net/wl724120268/article/details/103601322