file - Powershell - 如何列出文件并将其路径写入输出文件?

标签 file powershell

我想列出几个子目录中的 *.xml 文件。然后我想把他们的路径和他们的名字写到一个txt文件中。
我设法将名称写入 txt 文件,但是,我不知道如何添加它们的路径。我需要更改/添加什么?

Get-ChildItem path -recurse -include *.xml| ForEach-Object { $_.Name } > path\output.txt

感谢您的帮助!
干杯,
鸢尾花

最佳答案

FullName 将打印文件的完整路径。

Get-ChildItem path -recurse -include *.xml| ForEach-Object { $_.FullName } > path\output.txt

以下是此实例中返回的对象提供的属性列表: FileInfo

关于file - Powershell - 如何列出文件并将其路径写入输出文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21163410/

相关文章:

java - 获取java war文件中的资源文件夹

java - 如何使用 Java 在浏览器中启动文件下载?

ajax - node.js:在成功验证 get 请求后提供文件(特别是 apk)

powershell - PowerShell输出为HTML

powershell - 从 PowerShell 脚本将工作流事件添加到工具箱时遇到问题

c# - 在 Visual Studio 2017 中运行和调试 Powershell 模块

javascript - 如何使用 GWT 读取本地(客户端)文件?

windows - 文件扩展名

powershell - 列出域内远程计算机的硬盘信息

powershell - 在哈希表数组中搜索键的最简洁方法