我在这种格式的文件夹中有很多文件
constant_blah_blah_blah.png
Run Code Online (Sandbox Code Playgroud)
如何用空格替换下划线并使用PowerShell从中删除constant_?
提前致谢.
你可以试试这个
Get-childItem constant* | % {rename-item $_.name ($_.name -replace '_',' ')}
Get-childItem constant* | % {rename-item $_.name ($_.name -replace 'constant ','')}
Run Code Online (Sandbox Code Playgroud)
# gather all files that match the criteria
Get-ChildItem constant_* |
ForEach-Object {
# remove the "constant_" from the beginning and replace _ by space.
Rename-Item $_ ($_.Name -replace '^constant_' -replace '_', ' ')
}
Run Code Online (Sandbox Code Playgroud)
或更短:
ls constant_* | %{rni $_ ($_.Name -replace '^constant_' -replace '_', ' ')}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4294 次 |
| 最近记录: |