【问题标题】:Powershell - how do I list files and write their path into an output file?Powershell - 如何列出文件并将其路径写入输出文件?
【发布时间】:2014-02-05 10:56:39
【问题描述】:

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

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

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

【问题讨论】:

    标签: file powershell


    【解决方案1】:

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

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

    这是此实例中返回的对象提供的属性列表:FileInfoClass

    【讨论】:

      猜你喜欢
      • 2021-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多