所需功能
file1.txt -> file1.txt.deploy
file2.txt -> file2.txt.deploy
尝试#82
Get-ChildItem | ForEach-Object {
Rename-Item -NewName { $_.Name + ".deploy" }
}
Cannot evaluate parameter NewName because its argument is specified as a script block and there is no input
我做错了什么?
答案 0 :(得分:2)
如果您使用ForEach-Object
,则需要使用$_
来管道实际对象:
Get-ChildItem | ForEach-Object {
Rename-Item $_ -NewName { $_.Name + ".deploy" }
}
或者只是跳过ForEach-Object
,因为BartekB在评论中提及:
Get-ChildItem | Rename-Item -NewName { $_.Name + ".deploy" }