

















这是一个创建于 1146 天前的主题,其中的信息可能已经有所发展或是发生改变。
看 Powershell Rename-Item 文档时,有批量命名文件的 example ,代码如下:
Get-ChildItem *.txt | Rename-Item -NewName { $_.Name -replace '.txt','.log' }
无法理解 Get-ChildItem 获取的文件后,通过管道,具体是使用哪种方式传递给 Rename-Item ,以及传递了什么内容。
上面代码我的理解,Get-ChildItem 命令的结果通过管道传递给了 Rename-Item 的 Path 参数。但 Path 只接受 string 。如果管道是 ByValue 方式,传递的应该是 Object ,所以不是 ByValue 。如果是 ByPropertyName ,Get-ChildItem 获取的 FileInfo 对象并没有 Path 属性,理论上也无法传递。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。